magicalpanda/MagicalRecord — Issue #111: iOS 5 crash with "Database appears corrupt" while fetching in saveDataInBackgroundWithBlock
Author: appsperhaps
Created: 2011-12-15 06:20:45+00:00
State: open

Great framework, loved it so much after a recent project, that I'm now refactoring my production app to use it. Deleting lots of boilerplate code as I go.

However, I come across an issue running MR in iOS 5:

* App launches, and seeds about 20 entities on the default context (main thread) then saves.
* The app then downloads some data via ASIHTTPRequest, then in its download completion block I run **MRCoreDataAction saveDataInBackgroundWithBlock** that attempts to save those data. Within this block, it fetches (on the localContext) one of the seeded entity to be associated with new entities. This executeFetch will crash with the message:

> Core Data: annotation: -executeRequest: encountered exception = The database appears corrupt. (invalid primary key) with userInfo...

The way I got around it at the moment is to increase the **kCFCoreFoundationVersionNumber_iPhoneOS_5_0** (in CoreData+MagicalRecord.h) to something really large so that **THREAD_ISOLATION_MODE** is used instead of **PRIVATE_QUEUES_ENABLED**.

Is this a known issue in the framework? Has anyone comes across this issue, or have other ideas?

Thanks!
Jeff