Re: database locking issue

103 views
Skip to first unread message

Igor Sereda

unread,
Sep 14, 2012, 11:44:42 AM9/14/12
to sqlit...@googlegroups.com
Is there a concurrent read on the same database? If the database is locked for reading by another thread or process, you might get "database locked" immediately when you try to raise locking level to EXCLUSIVE (happens on commit). Try using st.setBusyTimeout() to let sqlite spin waiting for the lock.

Another thought, you don't put calls to st.dispose() into finally { ... } block, so it's possible that an open statement has leaked - which might prevent from committing too.

Hope this helps,
Igor


On Friday, September 14, 2012 6:43:38 PM UTC+4, lhw wrote:
I'm currently working on a student project and I ran into an issue with sqlite database locking which I can't seem to pin-point. The code in question: https://gist.github.com/3722276 
Now. The storeFriends method is called by one QueueManager and the storeKeywords by another. But both have the same supertype and similar implementation. While storeFriends works flawlessly storeKeywords always raises an Exception on db.exec("COMMIT") with database locked. Both methods are called each from one thread only. So there shouldn't be any Multi-Threading issues. I also tried storeKeywords without transactions as there mostly only about 3-15 keywords per transaction anyway. In which case the  database lock error comes up on step(). So either I am missing the big issue here, maybe I am doing transactions all wrong with this library or there is something I am overlooking everytime.
I hope you can help.

- lhw

lhw

unread,
Sep 14, 2012, 12:28:57 PM9/14/12
to sqlit...@googlegroups.com
Thank you for taking the time to answer. I added both your suggestions to my code and now it works perfectly. Now I just have to find out what causes the concurrent reading/statement as that shouldn't be happening in my test case.
Thanks again.

-lhw
Reply all
Reply to author
Forward
0 new messages