On Fri, 16 Oct 2009, Roger Binns wrote: > To: General Discussion of SQLite Database <sqlite-users@sqlite.org> > From: Roger Binns <rog...@rogerbinns.com> > Subject: Re: [sqlite] suggestions for avoiding "database locked" on ajax > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > P Kishor wrote: >> So, what suggestion might you all have for getting around this? > > Why not set a busy timeout? > > Roger
As each user's IP address is unique, you could use a LOCK column for the whole database, or a particular table. You could then store the IP address of the user initiating the transaction. When a transaction starts, you can use a trigger to test whether the LOCK column is NULL for empty. If so, set the LOCK column to value of the users IP address. If another user from a different IP address attempts a similar transaction, then block that transaction from continuing, until the LOCK on the other IP address has been removed. Once the transaction has finished, release the LOCK by clearing the user's IP address from the LOCK column by setting it back to NULL. I'm not sure how you would go about dealing with muliple transaction being stalled, and waiting to get the LOCK freed, so each one can continue. Maybe muliple retries, until the user's can get access to the db? Kind Regards, Keith Roberts ----------------------------------------------------------------- Websites: http://www.php-debuggers.net http://www.karsites.net http://www.raised-from-the-dead.org.uk All email addresses are challenge-response protected with TMDA [http://tmda.net] ----------------------------------------------------------------- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users