Re: SQLite Concurrency Issue

[email protected] (Mark Lawrence)
Newsgroups perl.dbi.users
Message-ID <[email protected]>
On Wed Dec 22, 2010 at 04:44:28PM -0800, David E. Wheeler wrote:
> On Dec 22, 2010, at 3:30 PM, <[email protected]> wrote:
> 
> > Maybe an obvious quesiton, but can you catch SQLITE_BUSY and just
> > loop and retry in your application code? Is there any reason not to
> > retry after a second or so? Such application retry logic is pretty
> > standard for transaction deadlock issues. 
> 
> I guess I could do that, but I'm going to have to do quite a bit of
> extra work to add the retry stuff. I might be able to use a lockfile,
> as well.
> 
> I'm hating both of these solutions.

I haven't used it, but there is an SQLite busy timeout value[1] (in ms)
that can be set to specify how long SQLite sleeps when access to a
table is (b)locked.

The function to get/set that value is also exported via DBD::SQLite[2].

[1] http://www.sqlite.org/c3ref/busy_timeout.html

[2] http://search.cpan.org/~msergeant/DBD-SQLite-1.14/lib/DBD/SQLite.pm#$dbh-%3Efunc%28_$ms,_%27busy_timeout%27_%29

Mark.
-- 
Mark Lawrence
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.