monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] RFC: do no exit mtn if database is locked


From: Nuno Lucas
Subject: Re: [Monotone-devel] RFC: do no exit mtn if database is locked
Date: Fri, 27 Oct 2006 17:33:59 +0100

On 10/27/06, Thomas Keller <address@hidden> wrote:
Hi all!

I've written (and attached) a small, yet incomplete patch to handle the
mtn error "Database is locked" from SQLite. SQLite has a special
function[0] with which it triggers a callback whenever SQLITE_BUSY pops
up (e.g. during sqlite3_exec). This callback has to return nonzero to
block any running request from returning immediately with SQLITE_BUSY
and could contain code to notify the user of waiting and putting the
current process to sleep (in the hope that the other process who also
uses the db exits some time).

The functionality you are implementing is already provided by
sqlite3_busy_timeout(), and handles the case of waiting a fixed time
(you could get a client "starved" for long periods of time with this
aproach), as long as sqlite3OsSleep() is implemented  with the
equivalent of usleep() (which posix and windows OS's do).

Also, by always retrying, you can get into a deadlock, as explained in
the documentation you have linked to.

You may want to give a look into the sqliteDefaultBusyCallback()
implementation (in the sqlite source file main.c), which is the one
setup by the sqlite3_busy_timeout() function.


Best regards,
~Nuno Lucas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]