Hi Simon I think you mean this "sqlite3_busy_timeout(db, 2000);"
I am already using this api with busy time of 2sec , but some of my codepaths didn't exit the process without closing the db. So I guess I am still going to fix that first. I don't want to increase this more than 2 sec, since there is a single connection, if the db is locked its some other problem that needs to be found and fix. Thanks Mayank -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin Sent: Thursday, July 24, 2014 4:09 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Sometimes when my process restarts, it returns error "database is locked" On 24 Jul 2014, at 8:21pm, Mayank Kumar (mayankum) <mayan...@cisco.com> wrote: > Thanks Simon. I found from the code, there are times when our process dies > without closing the db , so I will be fixing those. > > Regarding >> Do you call have a timeout value set before you make the API call which >> opens the database ? > How does this impact the locked db ? By default, if a process tried to access the database and is locked, SQLite immediately returns SQLITE_BUSY or SQLITE_LOCKED and you have to handle the problem in your own programming. If you set a timeout, after finding the database locked, SQLite will wait a short while (milliseconds) and then see if the database is unlocked yet. If not, it will was a little longer, then try again. If still locked it will wait a little longer then try again. It will keep waiting and retrying until the timeout period you set has passed. This is all done inside the SQLite API call and you don't have to do any of it inside your own programming. Many database locking problems are solved by setting a timeout of a couple of minutes. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users