Sqlite-net: Busy error

Created on 6 Feb 2017  路  2Comments  路  Source: praeclarum/sqlite-net

I have a couple restful requests running, which insert the results into a sqlite-net db.

The database insert part looks like:

                        int id = SelectOne(select);
                        if (id == 0)
                            return connection.Insert(obj);
                        else
                            return connection.Update(obj);

I have had to wrap this with a lock(), because if I don't, I sometimes get a sqlite "busy" error on the update part. Any thoughts on what might cause the busy error?

Question

Most helpful comment

I had a lot of "busy" errors and app crashes until I added FullMutex flag to the connection:

_connection = new SQLiteConnection(path, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex)

I also keep this connection unique and open during the whole app life cycle

All 2 comments

SQLite allows only one writer at a time.

https://www.sqlite.org/lockingv3.html

I had a lot of "busy" errors and app crashes until I added FullMutex flag to the connection:

_connection = new SQLiteConnection(path, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex)

I also keep this connection unique and open during the whole app life cycle

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newtoncw picture newtoncw  路  7Comments

shaman4k picture shaman4k  路  5Comments

rynjas picture rynjas  路  3Comments

acaliaro picture acaliaro  路  6Comments

Freddixx picture Freddixx  路  4Comments