I’m using an NSPrivateQueueConcurrencyType NSManagedObjectContext and a deadlock happens in the following situation.
On a background thread, a call to performBlock: is made. That block contains a executeFetchRequest:error: call.
While that block is executing, the main thread makes a call to performBlockAndWait:. The main thread waits while the block of the background thread finishes. That’s normal.
When the executeFetchRequest:error: call is made on the background’s thread block, a dead lock happens.
I imagine that the executeFetchRequest:error: is waiting for the main thread for the performBlockAndWait: to finishes.
Is that a bug? Or I don’t understand something? To me, all this code seems valid with the NSPrivateQueueConcurrencyType MOCs.
NSPrivateQueueConcurrencyType does not automagically make NSManagedObjectContext thread-safe. If you need to use Core Data on multiple threads, you should still use separate contexts for each thread.