Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash due to database lock #22

Open
veetil opened this issue Sep 24, 2015 · 4 comments
Open

Crash due to database lock #22

veetil opened this issue Sep 24, 2015 · 4 comments

Comments

@veetil
Copy link

veetil commented Sep 24, 2015

In my android code, SimpleNoSQL ocassionally crashes the app on start. Error message is that database is locked. Since there is not initDB function, how to handle this scenario.

id.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:924)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1618)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at com.colintmiller.simplenosql.db.SimpleNoSQLDBHelper.deleteBucket(SimpleNoSQLDBHelper.java:84)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at com.colintmiller.simplenosql.threading.DataDispatcher.delete(DataDispatcher.java:108)
09-21 18:13:31.008 25314-25521/com.fun.shopping E/AndroidRuntime: at com.colintmiller.simplenosql.threading.DataDispatcher.run(DataDispatcher.java:80)

@veetil veetil changed the title Crash due to Crash due to database lock Sep 24, 2015
@Jearil
Copy link
Owner

Jearil commented Sep 24, 2015

Interesting. Do you have some sample code to reproduce this? It looks like you're deleting a bucket at some point. When is this?

@veetil
Copy link
Author

veetil commented Sep 25, 2015

Sure. Here is a sample code I am using to delete buckets. This I am doing in my MainActivity, before starting any work to clear all cache on new app session.

        NoSQL.with(mcontext).using(Option.class)
                .bucketId("options")
                .delete();
        NoSQL.with(mcontext).using(OptionGroup.class)
                .bucketId("option_group")
                .delete();

I started seeing this issue mostly after using ProGuard. Although I did add the following lines to proguard.
-keep class com.colintmiller.** { ; }
-keepclassmembers class com.colintmiller.
* { ; }
-keep interface com.colintmiller.
* { ; }
-keep enum com.colintmiller.
* { *; }

@Jearil
Copy link
Owner

Jearil commented Sep 28, 2015

Can you reproduce it without proguard? If it's a progaurd problem, that's a bit different than an error in the library. I'll look into it though, it may there is something wrong with the locking code which should prevent multiple writes from happening at a time.

@Jearil
Copy link
Owner

Jearil commented Sep 28, 2015

Also, as a temporary work around, you can use:
NoSQL.with(mContext, 1).using(....
to prevent the error (since it seems to be a threading issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants