2015/10/15 21:53:34:350 < app did finish launching >
2015/10/15 21:53:34:351 Opening database at /var/mobile/Containers/Data/Application/06FAA9C2-6EF5-4654-95E6-6693C63231B9/Library/Application Support/Database/db.sqlite
2015/10/15 21:53:34:636 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollections:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 21:53:35:531 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 21:53:35:541 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 22:25:33:416 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a database
2015/10/15 22:25:37:263 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a database
2015/10/15 22:25:37:357 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a database
--
You received this message because you are subscribed to the Google Groups "YapDatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yapdatabase...@googlegroups.com.
To post to this group, send email to yapda...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There are a couple common culprits I can think of. If none of these are the offenders, then there are a few other things we can look into.- The database file itself is being “synced” by some cloud service. (In which case this probably also applies to the database WAL file too. Making it more than twice as likely to experience corruption.)
Are you storing the database file in such a way that a service is syncing it in the cloud? iCloud drive? Or dropbox? Etc?
- Using YapDatabase from more than one process simultaneously.Are you doing funky stuff involving Watches or TV’s that may involve multiple processes ?
- Are you using SQLCipher ?
On October 16, 2015 at 5:23:19 PM, Nathan Spindel (nat...@gmail.com) wrote:
--Hello,I'm using YapDatabase in a new iOS app. It's going great, except for an intermittent database corruption bug which causes data loss. This issue happens in the simulator and on multiple devices, and unfortunately I can't reliably reproduce it. The corruption occurs often enough that I need to (a) track it down (b) stop using YapDatabase. I'd greatly prefer the former. ;)Do you have advice on how to track this down? I've searched around, read Robbie's response in YapDatabase Issue 81 (same symptom) and the ensuing How To Corrupt An SQLite Database File, but none have led me to the root cause. Are there any specific practices or YapDatabase configuration/usage issues to look for that could be culprit?Here's a snippet of YapDatabaseTransaction logs after the corruption has started (after one day of flawless database use across multiple app launches). For what it's worth I've explicitly disabled iOS Data Protection so I don't think it's related (despite the 'file is encrypted' message). If it helps I'm using the default serializer/deserializer, the default database options, and latest release versions of all the things: YapDatabase 2.7.3, Xcode 7.0.2, iOS 9 SDK.2015/10/15 21:53:34:350 < app did finish launching >
2015/10/15 21:53:34:351 Opening database at /var/mobile/Containers/Data/Application/06FAA9C2-6EF5-4654-95E6-6693C63231B9/Library/Application Support/Database/db.sqlite
2015/10/15 21:53:34:636 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollections:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 21:53:35:531 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 21:53:35:541 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 11 database disk image is malformed
2015/10/15 22:25:33:416 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a database
2015/10/15 22:25:37:263 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a database
2015/10/15 22:25:37:357 YapDatabaseTransaction: _enumerateKeysAndObjectsInCollection:usingBlock:withFilter: - sqlite_step error: 26 file is encrypted or is not a databaseAny pointers would be greatly appreciated.Thanks much!Nathan
You received this message because you are subscribed to the Google Groups "YapDatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yapdatabase...@googlegroups.com.
To post to this group, send email to yapda...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "YapDatabase" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/yapdatabase/y-BmIVXGlJA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to yapdatabase...@googlegroups.com.
Thanks for your reply, Robbie! I've answered your questions in-line below.On Mon, Oct 19, 2015 at 9:31 AM, Robbie Hanson <robbie...@deusty.com> wrote:There are a couple common culprits I can think of. If none of these are the offenders, then there are a few other things we can look into.- The database file itself is being “synced” by some cloud service. (In which case this probably also applies to the database WAL file too. Making it more than twice as likely to experience corruption.)Are you storing the database file in such a way that a service is syncing it in the cloud? iCloud drive? Or dropbox? Etc?No - unless you count the standard iCloud Backup performed by the OS. Have other YapDatabase apps run into corruption issues with iCloud Backup?
Not that I’m aware of. But issue 2.2 (from https://www.sqlite.org/howtocorrupt.html) talks about a close() on a file descriptor possibly cancelling advisory locks. Which made me envision the OS opening the file in order to stream the contents to the backup. And then close()’ing it afterwards.
I can’t say this is for sure an issue. Especially since you’re only using the database from a single process. But it may be worth disabling iCloud backup for all 3 files just to be sure:
- database, wal, & shm
- Using YapDatabase from more than one process simultaneously.Are you doing funky stuff involving Watches or TV’s that may involve multiple processes ?The app just uses one iOS process.It might be worth mentioning that the app uses background fetch and periodically read/writes to the database in the background (this is still one process total, and both the foreground and background database updates use the same single YapDatabase object and connections).
I’m not aware of background read/writes to a local file having any issues.
- Are you using SQLCipher ?No.What should we look into next? Thanks again for your help in debugging this.
In YapDatabase.m, around line #699, comment out the following lines:
status = sqlite3_exec(db, "PRAGMA synchronous = NORMAL;", NULL, NULL, NULL);
if (status != SQLITE_OK)
{
YDBLogError(@"Error setting PRAGMA synchronous: %d %s", status, sqlite3_errmsg(db));
// This isn't critical, so we can continue.
}
Based on the documentation, this shouldn’t be an issue. But I’ve seen cases where the documentation has diverged from the implementation in the past. (Also concerning PRAGMA synchronous.)
This should have the effect of setting PRAGMA synchronous to FULL (the default) for the database connection that performs checkpoints.
Let me know if the problem disappears from this.