mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Deadlock while using .beginAsynchronous and ListMonitor #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SteveKChiu on GitHub (Jul 23, 2015).
It seems CoreStore can result in deadlock with .beginAsynchronous and ListMonitor, from my experiment:
If I change CoreStote.beginAsynchronous to CoreStote.beginSynchronous, then all are fine.
I trace the problem and find out:
parentContext.saveSynchronously(NSManagedObjectContext+Transaction.swift: 96)try! fetchedResultsController.performFetch()(ListMonitor.swift: 505)@SteveKChiu commented on GitHub (Jul 23, 2015):
For develop branch, but I think it apply to main branch too.
@JohnEstropia commented on GitHub (Jul 23, 2015):
@SteveKChiu This is probably a confusion caused by having two overloads for
AsynchronousDataTransaction'scommit()method:You are probably calling the
commit()method which was originally namedcommitAndWait(). In hindsight I should have left the name as it was to indicate blocking behavior. I'll push a fix soon.In the mean time, you can fix this on your side with either one of two ways:
CoreStore.monitorList(...)beforeCoreStore.beginAsynchronous(...); or,beginAsynchronous(...), calltransaction.commit { _ in }instead oftransaction.commit()@SteveKChiu commented on GitHub (Jul 23, 2015):
I actually had tried the asynchronous one, but it still had the same problem. Anyway, I end up found a solution to the problem, please see my pull request. I am not sure if all modifications are necessary, but I think there is no reason to use the 'wait' version call in most case.