Berkeley DB Reference Guide: Transaction Subsystem
Полезная информация

Berkeley DB Reference Guide: Transaction Subsystem

Cursor Stability

In the absence of locking, no guarantees are made about the stability of cursors in different processes or threads. However, the btree and recno access methods guarantee that cursor operations, interspersed with other cursor or non-cursor operations in the same thread of control (i.e., thread or single-threaded process), will always return keys in order and will return each non-deleted key/data pair exactly once. Because the hash access method uses a dynamic hashing algorithm, it cannot guarantee any form of stability in the presence of inserts and deletes unless locking is performed.

If locking was specified when the Berkeley DB file was opened, but transactions are not in effect, the access methods provide repeatable reads with respect to the cursor. That is, a DB_CURRENT call on the cursor is guaranteed to return the same record as was returned on the last call to the cursor.

In the presence of transactions, the access method calls between a call to txn_begin and a call to txn_abort or txn_commit provide degree 3 consistency. For all access methods, a cursor scan of the database performed within the context of a transaction is guaranteed to return each key/data pair once and only once, except in the following case. If, while performing a cursor scan using the hash access method, the transaction performing the scan inserts a new pair into the database, it is possible that duplicate key/data pairs will be returned.