php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51295 SQLite3::busyTimeout not existing
Submitted: 2010-03-14 08:29 UTC Modified: 2010-06-22 03:15 UTC
From: magicaltux@php.net Assigned: scottmac (profile)
Status: Closed Package: SQLite related
PHP Version: 5.3SVN-2010-03-14 (SVN) OS: Linux Gentoo 2.6.33
Private report: No CVE-ID: None
 [2010-03-14 08:29 UTC] magicaltux@php.net
Description:
------------
In SQLite3, method busyTimeout() is missing, and by default there is no busy 
handler.

In old SQLite extension, a default timeout of 60 seconds was set, and a 
busyTimeout() method was available to define the timeout.

I recently started with SQLite3 to have this kind of errors as load was growing 
on SELECT statement:

Warning: SQLite3Stmt::execute(): Unable to execute statement: database is locked

Some internet research showed that this could be fixed by setting a different 
busy timeout, and I noticed PHP wasn't setting any on SQLite3.

While I'm unsure about setting a default busyTimeout on SQLite3 (it currently 
have none, but PHP_5_3 is still young enough to change this kind of behaviour) 
it should be at least possible to set one.

Patch to add a SQLite3::busyTimeout() method (same behaviour as old 
SQLite::busyTimeout() method, with the exception this one has a true/false 
return value, while sqlite3_busy_timeout will always return SQLITE_OK, it may 
change in the future).

The patch:

https://ookoo.org/svn/snip/php_5_3-sqlite3-busytimeout-method.patch


Patches

php_5_3-sqlite3-busytimeout-method.patch (last revision 2010-03-14 07:29 UTC by magicaltux)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-19 12:15 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: scottmac
 [2010-06-07 07:00 UTC] magicaltux@php.net
Ok, I had some troubles to make a meaningful test for this bug (the php function 
is just calling the equivalent sqlite function), but in the end I got this.

http://ookoo.org/svn/snip/20100607_php_test_bug51295.php (didn't manage to 
attache this to this bug report, even renamed as .txt)

Anyway here it is. It forks, open a sqlite file and locks it, then the other 
process will try to access it with a 1 second busyTimeout then dumps the waited 
time and the result (should have failed with a 1 second delay with +/- 10ms)

Remaining steps includes converting this test to phpt and run it once to get the 
"right" output (I'll need to check doc to find the right format for phpt since 
it's been a while).
 [2010-06-09 09:29 UTC] ncoesel at dealogic dot nl
When using an Sqlite database from multiple processes there should always be a busy timeout. However this still doesn't prevent Sqlite from exiting prematurely. I posted a patch in bug report #51680 (which really is not a duplicate!!!) that also solves that problem.
 [2010-06-20 17:28 UTC] pajoye@php.net
-Status: Assigned +Status: Feedback
 [2010-06-20 17:28 UTC] pajoye@php.net
Can you create a valid phpt for the test please?
 [2010-06-20 17:30 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=300614
Log: - #51295, SQLite3::busyTimeout not existing
 [2010-06-21 13:06 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=300631
Log: MFB: Implemented FR #51295 (SQLite3::busyTimeout not existing). (Mark)
 [2010-06-22 03:15 UTC] felipe@php.net
-Status: Feedback +Status: Closed
 [2010-06-22 03:15 UTC] felipe@php.net
Implemented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC