Saturday, November 22, 2014 [Tweets] [Favorites]

Core Data Relationships Data Loss Bug

Tom Harrington notes that several developers (including James Dempsey and Rich Siegel) have encountered a bug with Core Data’s -[NSPersistentStoreCoordinator migratePersistentStore:toURL:options:withType:error:] method. This is supposed to copy the data store from one location to another, e.g. for making a backup. The frameworks may also call the method on your behalf, e.g. if the user does a Save As. The bug is that, on Yosemite and iOS 8, the method discards many-to-many relationships. This is actually worse than corrupting the file because the new file will still be readable, so it may not be obvious that it’s missing some of the data. The bug is reputed to affect all store types.

(DropDMG and EagleFiler use Core Data but not many-to-many relationships, so I don’t think they are affected.)

Update (2014-11-24): Harrington has filed a bug and posted a sample project.

Update (2015-03-10): This is fixed in Mac OS X 10.10.2 and iOS 8.2.

4 Comments

I don't understand how crap like this ships or how it isn't priority number 1 to fix once discovered. Data loss / corruption is the worst of all worlds. Even moreso in a framework built for dealing with data that's going to amplify the effect of the bug. I'd drop everything to fix data loss / corruption issues for my customers (stay up all night, cancel plans, weddings, etc.).

It seems like the best way to get Apple to fix their shit is to get the mainstream media to report it and paint Apple in a bad light.

[…] does fix the nasty Core Data relationships data loss bug, though this is not yet fixed in […]

[…] done responsibly, it’s a good pragmatic solution. Bugs are inevitable, and sometimes it is months or years before they are fixed, so Apple should not stand in the way of people trying to mitigate […]

[…] Core Data Relationships Data Loss Bug when calling migratePersistentStore […]

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment