On Tue, Dec 20, 2011 at 6:08 AM, Simon Slavin <slav...@bigfraud.org> wrote:
>
> First, there's more than one way of using SQLite3 from PHP.  There's also the 
> interface SQLite3:: which is a much thinner wrapper around the basic SQLite C 
> library.  I have no way of knowing what proportion of programmers use one 
> library or the other.

I started using SQLite with PHP in version 5.2.x, when there wasn't
SQLite3:: interface, so I chose to use PDO. Moreover, I don't want to
lock myself into SQLite, PDO provides a somewhat more flexible
approach.


> As long as you set an acceptable timeout, which you do with one of these 
> calls depending which library you're using
>
> <http://php.net/manual/en/pdo.setattribute.php>
>
> <http://uk.php.net/manual/en/sqlite3.busytimeout.php>
>
> your web service probably isn't going to run into problems.  What might be 
> worrying you right now is the result of the default timeout being zero, 
> something which is arguably weird.  In other words, unless you specify a 
> timeout yourself any report of a lock is instantly treated like an error.  
> Set your timeout to one second or five seconds and the behaviour will be more 
> reasonable.

I'd done some research into this since I asked my question and learned
some things. According to http://bugs.php.net/bug.php?id=38182 and
http://www.serverphorums.com/read.php?7,118071, PDO_SQLITE defaults to
a 60 second busy timeout. This should be enough.

> Second, most transactions and locks in SQLite from PHP are fleeting.  
> Generally you want your web page to list some records or do one update.  You 
> wouldn't have a process keep a lock active for a long time because this would 
> correspond to your server taking a long time to show a web page, and nobody 
> wants that.  So a lock by one process probably isn't going to last very long 
> -- probably a fraction of a second.  Access for a web page is unlikely to 
> involve deadlock because of the nature of web pages: they generally don't 
> interact with the user while a transaction is open.


One would think so :) But Drupal people have run into the opposite
(http://drupal.org/node/1120020 and
http://stackoverflow.com/questions/6108602/avoiding-locked-sqlite-database-timeouts-with-php-pdo).
This seems to happen for them mostly when they are indexing their data
a visitor to a site requests a page. Apparently, their indexing tasks
is long running and write intensive. I think they should rework this
tasks.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to