Uploaded image for project: 'Couchbase Lite'
  1. Couchbase Lite
  2. CBL-3086

Corrupted database error on copy

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • 3.1.0
    • 3.1.0
    • LiteCore
    • Security Level: Public
    • None

    Description

      I have code that will reliably produce a "Corrupt database" error.

      • Unpack a zip file into a very large database (provided by a forum poster), to Android external storage
      • Run an integrity check on the DB. It passes
      • Attempt to copy the database from external storage to internal storage (Database.copy) Copy fails with the corrupt data message
      • Run an integrity check on the DB. It passes

      After the attempted copy, the source database directory looks like this:

      27|shamu:/sdcard/Android/data/com.couchbase.android.corruption/files/crash_test_dummies/testdb.cblite2 # ls -al
      total 17207352
      drwxrwx--x 3 u0_a296 sdcard_rw       4096 2022-05-05 12:35 .
      drwxrwx--x 3 u0_a296 sdcard_rw       4096 2022-05-05 12:35 ..
      drwxrwx--x 2 u0_a296 sdcard_rw       4096 2022-05-05 12:24 Attachments
      -rw-rw---- 1 u0_a296 sdcard_rw 8804868096 2022-05-05 12:35 db.sqlite3
      -rw-rw---- 1 u0_a296 sdcard_rw      32768 2022-05-05 12:37 db.sqlite3-shm
      

      The size of the .sqlite file seems about right.

      The target directory is empty.

      Here is the debug-level log for the failure:

      3004:05-05 12:55:13.745 20613 20713 I DBTest  : copy: /storage/emulated/0/Android/data/com.couchbase.android.corruption/files/crash_test_dummies/testdb.cblite2 -> testdb@/data/data/com.couchbase.android.corruption/files/crash_test_dummies
      3005:05-05 12:55:13.746 20613 20713 I CouchbaseLite/DATABASE: Copying prebuilt database from /storage/emulated/0/Android/data/com.couchbase.android.corruption/files/crash_test_dummies/testdb.cblite2/ to /data/data/com.couchbase.android.corruption/files/crash_test_dummies/testdb.cblite2
      3009:05-05 12:55:17.493 20613 20713 I CouchbaseLite/DATABASE: {N8litecore8DataFile6SharedE#1}==> N8litecore8DataFile6SharedE 0x87aa432c @0x87aa432c
      3010:05-05 12:55:17.494 20613 20713 D CouchbaseLite/DATABASE: {N8litecore8DataFile6SharedE#1} created for DataFile 0x8d5b8340 at /data/data/com.couchbase.android.corruption/files/crash_test_dummies/.cblite/YHVID9/db.sqlite3
      3011:05-05 12:55:17.494 20613 20713 I CouchbaseLite/DATABASE: {DB#2}==> N8litecore14SQLiteDataFileE /data/data/com.couchbase.android.corruption/files/crash_test_dummies/.cblite/YHVID9/db.sqlite3 @0x8d5b8340
      3012:05-05 12:55:17.494 20613 20713 I CouchbaseLite/DATABASE: {DB#2} Opening database
      3013:05-05 12:55:17.496 20613 20713 I CouchbaseLite/DATABASE: PRAGMA cache_size=-10240; PRAGMA mmap_size=52428800; PRAGMA synchronous=normal; PRAGMA journal_size_limit=5242880; PRAGMA case_sensitive_like=true
      3014:05-05 12:55:17.496 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sql FROM sqlite_master WHERE name = ? AND type = ? AND tbl_name = ?
      3015:05-05 12:55:17.497 20613 20713 I CouchbaseLite/DATABASE: Compiling SQL "SELECT sequence, flags, null, version, body, extra FROM kv_info WHERE key=?"
      3016:05-05 12:55:17.497 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sequence, flags, null, version, body, extra FROM kv_info WHERE key=?
      3017:05-05 12:55:17.497 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sql FROM sqlite_master WHERE name = ? AND type = ? AND tbl_name = ?
      3018:05-05 12:55:17.498 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sql FROM sqlite_master WHERE name = ? AND type = ? AND tbl_name = ?
      3019:05-05 12:55:17.498 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sql FROM sqlite_master WHERE name = ? AND type = ? AND tbl_name = ?
      3020:05-05 12:55:17.498 20613 20713 I CouchbaseLite/DATABASE: ... SELECT sql FROM sqlite_master WHERE name = ? AND type = ? AND tbl_name = ?
      3021:05-05 12:55:17.498 20613 20713 I CouchbaseLite/DATABASE: CREATE TEMP VIEW IF NOT EXISTS all_default (key,sequence,flags,version,body,extra,expiration) AS SELECT key,sequence,flags,version,body,extra,expiration from kv_default UNION ALL SELECT key,sequence,flags,version,body,extra,expiration from kv_del_default
      3022:05-05 12:55:17.499 20613 20713 I CouchbaseLite/DATABASE: {N8litecore14CollectionImplE#3}==> N8litecore14CollectionImplE YHVID9/_default @0xa2139a28
      3023:05-05 12:55:17.499 20613 20713 I CouchbaseLite/DATABASE: {N8litecore14CollectionImplE#3} Instantiated
      3024:05-05 12:55:17.500 20613 20713 I CouchbaseLite/DATABASE: ... SELECT substr(name,4) FROM sqlite_master WHERE type='table' AND name GLOB 'kv_*' AND NOT name GLOB 'kv_del_*'
      3025:05-05 12:55:17.500 20613 20713 I CouchbaseLite/DATABASE: Compiling SQL "SELECT min(expiration) FROM kv_default"
      3026:05-05 12:55:17.501 20613 20713 I CouchbaseLite/DATABASE: ... SELECT min(expiration) FROM kv_default
      3027:05-05 12:55:17.522 20613 20713 E CouchbaseLite/DATABASE: database disk image is malformed (11/11)
      3028:05-05 12:55:17.523 20613 20713 E CouchbaseLite/DATABASE: database disk image is malformed (11/11)
      3029:05-05 12:55:17.523 20613 20713 V CouchbaseLite/DATABASE: PRAGMA optimize ... 400
      3030:05-05 12:55:17.524 20613 20713 I CouchbaseLite/DATABASE: ... PRAGMA page_count
      3031:05-05 12:55:17.524 20613 20713 I CouchbaseLite/DATABASE: ... PRAGMA freelist_count
      3032:05-05 12:55:17.525 20613 20713 V CouchbaseLite/DATABASE: {DB#2} Housekeeping: 0 of 2149630 pages free (0%)
      3033:05-05 12:55:17.704 20613 20713 V CouchbaseLite/DATABASE: {DB#2} Closed SQLite database
      3034:05-05 12:55:17.705 20613 20713 I CouchbaseLite/DATABASE: {DB#2} Closing database
      3035:05-05 12:55:17.705 20613 20713 I CouchbaseLite/DATABASE: {N8litecore14CollectionImplE#3} Closed
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              jianmin.zhao Jianmin Zhao
              blake.meike Blake Meike
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty