On Mon, Aug 24, 2015 at 4:38 PM, Simon Slavin <slavins at bigfraud.org> wrote:
> > On 24 Aug 2015, at 3:03pm, Luc Andre <landre3567 at gmail.com> wrote: > > > PHP Notice: SQLite3Stmt::execute(): Unable to execute statement: database > > is locked > > SQLite3::prepare(): Unable to prepare statement: 5, database is locked > > SQLite3::querySingle(): Unable to execute statement: database is locked > > > > We can not understand how a read only file can get locked. > > Although the connection you're using is readonly, another program may have > the same database file open for writing. So your readonly thread has to > check to see that nothing is making changes to the file. Occasionally two > of your threads make this check at the same time and argue with one-another > about who goes first. > > I'm sure no process open the file using the SQLite API in write mode. If you suspect a cron job that open open the file (as a regular binary file) in rw mode, I doubt it, but the SQLIte opening should have failed, and the opening is always fine. > > Any hint / fix ? > > For every connection to the database set a timeout using this function: > > <http://php.net/manual/en/sqlite3.busytimeout.php> > > which will look something like > > $dbConnection->busyTimeout(300000); > > I'm using 5 minutes just to give an unattended program time to survive a > network problem. I don't expect any access to every really take 5 minutes. > > We already did a $dbConnection->busyTimeout(500); (500ms is already huge for our web server latency) with no luck. > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >