Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data store corruption

A handful of customers for my iPhone app are experiencing Core Data store corruption (I assume so, since the error is "Failed to save to data store: Operation could not be completed. (Cocoa error 259.)")

Has anyone else experienced this kind of store corruption? I am worried since I aim to soon push an update which performs a schema migration, and I am worried that this will expose even more problems.

I had assumed that the Core Data/SQLlite APIs use atomic operations and are immune to corruption except if the underlying filesystem experiences corruption.

Is there a way to reduce/prevent corruption, and a way to reproduce the corruption so I can test this (I have been unsuccessful thus far).

Edit:

Also getting this error: "The database at /var/mobile/Applications//Documents/foo.sqlite is corrupted. SQLite error code 11, database disk image is malformed."

like image 365
sehugg Avatar asked Apr 30 '10 01:04

sehugg


People also ask

What is data corruption in database?

Data corruption refers to errors in computer data that occur during writing, reading, storage, transmission, or processing, which introduce unintended changes to the original data. Computer, transmission, and storage systems use a number of measures to provide end-to-end data integrity, or lack of errors.

What is Core Data store?

Core Data provides an in-memory persistent store and three disk-based persistent stores, as described in Table 16-1. The binary store ( NSBinaryStoreType ) is an atomic store, as is the XML store ( NSXMLStoreType ). You can also create custom store types, atomic and incremental.

Should I enable Core Data?

The next time you need to store data, you should have a better idea of your options. Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.

What is Core Data database?

Core Data is a framework that you use to manage the model layer objects in your application. It provides generalized and automated solutions to common tasks associated with object life cycle and object graph management, including persistence.


1 Answers

It happens to me when I manually overwrote my Base.sqlite without deleting Base.sqlite-wal and Base.sqlite-shm. Indeed, these files are new SQLite 3.7 features, maybe added in iOS 7.

To resolve the problem, I deleted Base.sqlite-* and sqlite regenerated them from my new base version.

like image 142
Martin Avatar answered Oct 01 '22 16:10

Martin