On 10/12/07, Richard Klein <[EMAIL PROTECTED]> wrote:

> (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?)

Correct.

> (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?

A RESERVED lock indicates a process is planning to write to the
database file sometime in the future, so everyone else must be read
only.  It blocks future writers.

A process holds a RESERVED lock as long as it has changes to make
(because it has executed an INSERT or similar), but those changes are
still held within its own cache and no COMMIT has been executed, so it
doesn't need to actually modify the file yet.  New readers (SHARED)
are therefore okay.

It will be promoted to PENDING when it must modify the file to proceed.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to