Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Deadlock during the NSManagedObjectContext's executeFetchRequest #114

Closed
wants to merge 1 commit into from

1 participant

@smpete

Before the thread isolation mode was added we were experiencing deadlocks when run in iOS 5. Locking and unlocking the NSPersistentStore before and after the executeFetchRequest seems to have solved it.

Not sure how valid this is anymore that thread isolation is added. I'm experiencing the same problem as issue #111 when run in thread isolation mode so for now we must run in private queue mode on iOS 5 with this locking scheme.

Peter Elliott Running in Private Queue mode in iOS 5, experiencing deadlock when ex…
…ecuting the fetch request. Locking the persistent store before performing the fetch fixes it.
71a54c8
@smpete

No longer relevant with the fixes to private queue mode. There was a copy paste error in my commit comment - should've read when running in Thread Isolation mode in iOS5. But that is moot now...

@smpete smpete closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 19, 2011
  1. Running in Private Queue mode in iOS 5, experiencing deadlock when ex…

    Peter Elliott authored
    …ecuting the fetch request. Locking the persistent store before performing the fetch fixes it.
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 Source/Categories/NSManagedObject+MagicalRecord.m
View
10 Source/Categories/NSManagedObject+MagicalRecord.m
@@ -26,9 +26,19 @@ + (NSUInteger) MR_defaultBatchSize
+ (NSArray *) MR_executeFetchRequest:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context
{
NSError *error = nil;
+
+ PRIVATE_QUEUES_ENABLED
+ (
+ [[context persistentStoreCoordinator] lock];
+ )
NSArray *results = [context executeFetchRequest:request error:&error];
+ PRIVATE_QUEUES_ENABLED
+ (
+ [[context persistentStoreCoordinator] unlock];
+ )
+
if (results == nil)
{
[MagicalRecordHelpers handleErrors:error];
Something went wrong with that request. Please try again.