From 780b92ada9afcf1d58085a83a0b9e6bc982203d1 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 17 Feb 2015 17:25:57 +0000 Subject: Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz. --- docs/programmer_reference/lock_cam_conv.html | 91 ++++++++++++++++++---------- 1 file changed, 58 insertions(+), 33 deletions(-) (limited to 'docs/programmer_reference/lock_cam_conv.html') diff --git a/docs/programmer_reference/lock_cam_conv.html b/docs/programmer_reference/lock_cam_conv.html index a6a3c216..5ad78b9c 100644 --- a/docs/programmer_reference/lock_cam_conv.html +++ b/docs/programmer_reference/lock_cam_conv.html @@ -14,7 +14,7 @@ -

The Berkeley DB Concurrent Data Store product has a simple set of conventions for locking. It -provides multiple-reader/single-writer semantics, but not per-page -locking or transaction recoverability. As such, it does its locking -entirely in the Berkeley DB interface layer.

-

The object it locks is the file, identified by its unique file number. -The locking matrix is not one of the two standard lock modes, instead, -we use a four-lock set, consisting of the following:

+

+ The Berkeley DB Concurrent Data Store product has a simple + set of conventions for locking. It provides + multiple-reader/single-writer semantics, but not per-page + locking or transaction recoverability. As such, it does its + locking entirely in the Berkeley DB interface layer. +

+

+ The object it locks is the file, identified by its unique + file number. The locking matrix is not one of the two standard + lock modes, instead, we use a four-lock set, consisting of the + following: +

DB_LOCK_NG
-
not granted (always 0)
+
+ not granted (always 0) +
DB_LOCK_READ
-
read (shared)
+
+ read (shared) +
DB_LOCK_WRITE
-
write (exclusive)
+
+ write (exclusive) +
DB_LOCK_IWRITE
-
intention-to-write (shared with NG and READ, but conflicts with WRITE and IWRITE)
+
+ intention-to-write (shared with NG and READ, but + conflicts with WRITE and IWRITE) +
-

The IWRITE lock is used for cursors that will be used for updating -(IWRITE locks are implicitly obtained for write operations through the -Berkeley DB handles, for example, DB->put() or DB->del()). While -the cursor is reading, the IWRITE lock is held; but as soon as the -cursor is about to modify the database, the IWRITE is upgraded to a -WRITE lock. This upgrade blocks until all readers have exited the -database. Because only one IWRITE lock is allowed at any one time, no -two cursors can ever try to upgrade to a WRITE lock at the same time, -and therefore deadlocks are prevented, which is essential because Berkeley DB Concurrent Data Store -does not include deadlock detection and recovery.

-

Applications that need to lock compatibly with Berkeley DB Concurrent Data Store must obey the -following rules:

+

+ The IWRITE lock is used for cursors that will be used for + updating (IWRITE locks are implicitly obtained for write + operations through the Berkeley DB handles, for example, + DB->put() or DB->del()). While the cursor is reading, the IWRITE + lock is held; but as soon as the cursor is about to modify the + database, the IWRITE is upgraded to a WRITE lock. This upgrade + blocks until all readers have exited the database. Because + only one IWRITE lock is allowed at any one time, no two + cursors can ever try to upgrade to a WRITE lock at the same + time, and therefore deadlocks are prevented, which is + essential because Berkeley DB Concurrent Data Store does not + include deadlock detection and recovery. +

+

+ Applications that need to lock compatibly with Berkeley DB + Concurrent Data Store must obey the following rules: +

    -
  1. Use only lock modes DB_LOCK_NG, DB_LOCK_READ, DB_LOCK_WRITE, -DB_LOCK_IWRITE.
  2. -
  3. Never attempt to acquire a WRITE lock on an object that is -already locked with a READ lock.
  4. +
  5. + Use only lock modes DB_LOCK_NG, DB_LOCK_READ, + DB_LOCK_WRITE, DB_LOCK_IWRITE. +
  6. +
  7. + Never attempt to acquire a WRITE lock on an object + that is already locked with a READ lock. +
@@ -97,11 +120,13 @@ already locked with a READ lock.  Next - Locking with transactions: two-phase locking  + Locking with transactions: two-phase + locking  Home -  Berkeley DB Transactional Data Store locking conventions +  Berkeley DB Transactional Data + Store locking conventions -- cgit v1.2.1