iOS database failing to open with "Domain: SQLite Code: 11 NSLocalizedDescription: database disk image is malformed"

We are seeing a rare issue reported (0.15% of users) where a user starts our app and the app fails as the database can’t open. For these devices we see the following on our error logging platform…

Domain: SQLite Code: 11 NSLocalizedDescription: database disk image is malformed

Restarting the app does not solve it. If they restart their device and wait for a period of time (1 minute is the shortest amount we have asked someone to wait so far), then it will then successfully open the database. If they open the app immediately on restarting they get the same error.

We are using couchbase 1.3.2 (with a few patches… https://github.com/tophatch/couchbase-lite-ios/tree/concepts/1.3.2_patched)
We have logs of this happening on iOS 10.2 and 10.1.1
All devices are iPad Pro, but our user base is heavily skewed to that device, so it may not be significant.

Any ideas what the problem might be?

I have no idea what could be going on if restarting and waiting makes a difference. If SQLite reports file corruption, that should be something intrinsic to the file that wouldn’t go away on its own.

What is the file protection entitlement of your app set to?

Do you use database encryption (i.e. SQLCipher)?

What is the file protection entitlement of your app set to?

It is off

Do you use database encryption (i.e. SQLCipher)?

No, we do not.

We do this when initializing Couchbase

    CBLManagerOptions options;
    options.fileProtection = NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication;

Sorry, I’m stumped! Please file an issue on Github. I’m not sure how we can troubleshoot this if it’s not reproducible, though :frowning:

Done… https://github.com/couchbase/couchbase-lite-ios/issues/1569

If and when we find out more we will update the issue.