CouchbaseLite/DATABASE: database disk image is malformed (11/11)

Hi,

I’m keeping an instance of CouchbaseLite db in the SD Card. And the database is getting malformed at times.

I’m performing database open and close for each transaction and still facing the same issue. Currently, I’m using version ‘2.5.0’.

Please advice.

06-10 01:33:27.981 25421-26132 E/CouchbaseLite/DATABASE: database disk image is malformed (11/11)
06-10 01:33:27.983 25421-26132 E/DB error: Issue occurreddatabase disk image is malformed
06-10 01:33:27.983 25421-26132 W/System.err: CouchbaseLiteException{domain=‘CouchbaseLite’, code=15, msg=database disk image is malformed}
06-10 01:33:27.983 25421-26132 W/System.err: at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:51)
06-10 01:33:27.983 25421-26132 W/System.err: at com.couchbase.lite.CBLStatus.convertException(CBLStatus.java:55)
06-10 01:33:27.984 25421-26132 W/System.err: at com.couchbase.lite.AbstractDatabase.save(AbstractDatabase.java:1211)
06-10 01:33:27.984 25421-26132 W/System.err: at com.couchbase.lite.AbstractDatabase.save(AbstractDatabase.java:295)
06-10 01:33:27.984 25421-26132 W/System.err: at com.couchbase.lite.Database.save(Database.java:27)
06-10 01:33:27.984 25421-26132 W/System.err: at com.couchbase.lite.AbstractDatabase.save(AbstractDatabase.java:274)
06-10 01:33:27.984 25421-26132 W/System.err: at com.couchbase.lite.Database.save(Database.java:27)

SD cards are known to be unreliable — they’re 21st century floppy disks.

Have you done a filesystem check on the SD card afterwards, to make sure it isn’t corrupted? Also, you can try mounting the SD card on a PC and using the sqlite3 command line tool that comes with SQLite to check the database:

$ sqlite3 /path/to/database.cblite2/db.sqlite3
sqlite> pragma integrity_check;

This will complain that it can’t check indexes because of unregistered SQL functions; that’s normal. But if it reports other problems, the database is indeed corrupt.

If you run the same workload on the device’s internal storage, do you ever get corruption? If not, that would definitely point toward the card as the source of the problem.