amitshekhariitbhu / Android-Debug-Database

A library for debugging android databases and shared preferences - Make Debugging Great Again
https://outcomeschool.com
Apache License 2.0
8.39k stars 872 forks source link

Android-Debug-Database prevents Room from persisting data. #137

Open aaron-dunigan-atlee opened 5 years ago

aaron-dunigan-atlee commented 5 years ago

I'm using this library with Room 1.1.1., running my app on an emulated Nexus 5X, API 26. Everything works fine at first: I can view the database correctly. But AFTER I have viewed the database using Android-Debug-Database, my db only persists ONE more insertion. After that, all attempted INSERT commands don't get persisted... no errors, code runs smoothly as if the database were updated, but when I view the db, the extra INSERTs aren't there. I spent hours trying to find the bug in my code, only to realize that it was this library that was causing the bug. After removing A-D-D, all INSERT commands work correctly.

amitshekhariitbhu commented 5 years ago

Oh... Let me verify it.

aaron-dunigan-atlee commented 5 years ago

Thanks for looking into it. If you want to test it against my code, it's at https://github.com/aaron-dunigan-atlee/jfk-hyannis-museum-virtual-tour/commit/9e3636ef027c910c0d4d61baed541c4ace0e0e67 (The commit that says "Database not working") To add to the database, you'll need to scan QR codes; I've attached a few samples in the format that my app recognizes. This seems like a useful library... if you can fix this bug, I'll keep using it. barcode_1000 barcode_1001 barcode_2000 barcode_2001

SilviaSantano commented 5 years ago

I had just the same issue @aaron-dunigan-atlee describes. Unfortunately it took me also a very long time to find out what was causing my app not to persist the DB...

AndreasBackx commented 5 years ago

I am experiencing the same issue with Room 2.1.0-alpha01 and Android-Debug-Database 1.0.4. It somehow is corrupting my database as well and subsequent queries can result in exception: disk I/O error (code 522 SQLITE_IOERR_SHORT_READ).

MarioNoll commented 5 years ago

Same issue with Room 2.1.0-alpha03 and Android-Debug-Database 1.0.4.

rafalplonka commented 5 years ago

Same issue android.arch.persistence.room:runtime:1.1.1 com.amitshekhar.android:debug-db:1.0.4

jhwsx commented 5 years ago

Same isssue here android.arch.persistence.room:runtime:1.1.0 com.amitshekhar.android:debug-db:1.0.4

I have noticed that the return value from insert operation is ok, but I can't see the item in db online. In fact, after I kill my app and reload data from database, I CANNOT see my item that I want. Therefore, I doubt that there is something wrong with debug-db. I remove it and do the same operatoions, everything is ok.

ernestoyaquello commented 5 years ago

Same issue here as well:

implementation "androidx.room:room-runtime:2.1.0-alpha04"
kapt "androidx.room:room-compiler:2.1.0-alpha04"
testImplementation "androidx.room:room-testing:2.1.0-alpha04"

debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
planobrett commented 5 years ago

Same issue here. It seems that refreshing the web page a few times causes write operations to cease. The in-memory DB works just fine, but upon re-deploying, a crash, or restarting the app, it can only load what the DB has written to disk, and the data loss becomes apparent.

xordonkey commented 5 years ago

Hi, I could reproduce the same issue and analyze the cause. I don't think it is related to this project, although there should be a change regarding database download function in the browser.

Sqlite3 database consists of 3 files, all 3 files are needed in order to have full data content:

  1. _db
  2. _db-shm
  3. _db-wal

When you click the download button in the web-gui, you only get the _db file, thus you won't see the full data set. It is quite tricky because you won't get an error in the sqlite viewer, and the 2 missing files are created on the fly (I verified with several db viewer tools).

In order to verify this theory I used 'adb pull' with the emulator but also 'adb backup' with a real device. In both cases all data sets are there, as long as you pull all three files! There is no difference in having a dependency to this android debug artifact.

Never-the-less I would suggest the following fix: "Clicking the download button, starts zip (or tar.gz) archive download with 3 files as content, namely _db, _db-shm, _db-wal."

The single file download is useless with sqlite3.

Dabada commented 5 years ago

Same issue here. It seems that refreshing the web page a few times causes write operations to cease. The in-memory DB works just fine, but upon re-deploying, a crash, or restarting the app, it can only load what the DB has written to disk, and the data loss becomes apparent.

Same here. At every web page refresh A-D-D try to change DB journal_mode to PERSIST and crash. No more update or insert are possible after that !

E/SQLiteLog: (5) statement aborts at 2: [PRAGMA journal_mode=PERSIST]

W/SQLiteConnection: Could not change the database journal mode of '/data/user/0/wiped/databases/wiped' from 'wal' to 'PERSIST' because the database is locked. This usually means that there are other open connections to the database which prevents the database from enabling or disabling write-ahead logging mode. Proceeding without changing the journal mode.

abhinav-adtechs commented 4 years ago

I'm kind of dependent on this library. Is this issue being taken up? @amitshekhariitbhu

amitshekhariitbhu commented 4 years ago

@abhinav-adtechs Please let me know which version of the libraries you are using for both Room and Android-Debug-Database

hlinero commented 4 years ago

Is there any updated regarding this problem? I am experiencing the same situation