The RESERVED lock increases concurrency by preventing other processes
from gaining an EXCLUSIVE lock while still permitting reads. A PENDING
lock prevents read (SHARED) locks being acquired preparatory to setting
an EXCLUSIVE lock.
The thread or process which holds a RESERVED lock is eventually going to
promote it to EXCLUSIVE and alter the database but until the commit is
launched readers are still given access to the database. In some ways
you could think of a RESERVED lock as being a lock on the journal file.
Richard Klein wrote:
Hello all,
I'm in the process of upgrading from SQLite 2
to SQLite 3, and am trying to understand the
new lock states that version 3 introduced.
I need this understanding because I will be
porting SQLite 3 to an embedded OS that has
no file locking API, and I don't want to use
the "old-school" mechanism of having a .lock
file (too slow).
I have a couple of questions:
(1) Can more than one process have a PENDING
lock on a database? (I'm guessing that the
answer is "no". My guess is that if one
process has a PENDING lock on a database,
then all the other processes that have
opened that database have either no lock
or a SHARED lock on the database. I'm
further guessing that when all the SHARED
locks eventually drop away, the PENDING lock
is automatically promoted to EXCLUSIVE.
Do I have this right?)
(2) What is the purpose of the RESERVED lock?
Since it doesn't seem to lead (directly or
indirectly) to the PENDING or EXCLUSIVE state,
and since it doesn't prevent other processes
from acquiring SHARED locks, what is it good
for?
Thanks in advance,
- Richard Klein
------------------------------------------------------------------------
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------