[pybsddb] BDB 5 specific queue locking failure: Lock table is out of available object entries

Dmitry Dvoinikov dmitry at targeted.org
Fri Aug 3 14:40:58 CEST 2012


Hello all !

I've encountered a problem, and while I'm almost certain it is the Berkeley DB problem,
not bsddb3's, but it manifests in my Python program and I post it here in hope that some
of you BDB wizards out there could further isolate the problem and possibly report it.

Anyway, the scenario is as follows:

1. Push more records to a queue than you have lockers/objects. This fails and it's expected.
2. As the transaction has been aborted, the queue should still be empty.
3. Now try to create a cursor on the queue and first it. Surprisingly, this fails
   and the error is

MemoryError: (12, 'Not enough space -- Lock table is out of available object entries')

The problem is reproducible under BDB 5.x. Under BDB 4.x everything works as expected,
the cursor just points to the head of an empty queue i.e. nowhere.

Here is the script:
-----------------------------------------
from os import path as os_path
from bsddb3 import db as bsddb
from tempfile import mkdtemp

# CREATE AN ENVIRONMENT

env = bsddb.DBEnv()
env.set_tx_max(1)
env.set_lk_max_locks(16384)
env.set_lk_max_lockers(8192)
env.set_lk_max_objects(8192)
env.set_flags(bsddb.DB_AUTO_COMMIT | bsddb.DB_TXN_NOWAIT, 1)

dir = mkdtemp()
env.open(dir, bsddb.DB_CREATE | bsddb.DB_PRIVATE | bsddb.DB_INIT_LOCK | bsddb.DB_INIT_MPOOL | bsddb.DB_INIT_TXN | bsddb.DB_INIT_LOG)

# CREATE A QUEUE

q = bsddb.DB(env)
q.open(os_path.join(dir, "queue"), None, bsddb.DB_QUEUE, bsddb.DB_CREATE)

# PUSH MORE RECORDS THAN ALLOWED

txn = env.txn_begin(None, bsddb.DB_TXN_NOWAIT)
try:
    for i in range(8192):
        q.append(b"", txn)
except MemoryError: # expecting and ignoring MemoryError, transaction is aborted
    txn.abort()
else:
    assert False, "SHOULD NOT SEE ME" # make sure it happened

# AS THE TRANSACTION HAS BEEN ABORTED, THE QUEUE IS EMPTY

txn = env.txn_begin(None, bsddb.DB_TXN_NOWAIT)
crs = q.cursor(txn)

print("AND NOW FOR THE FAILURE:")
print("************************")

crs.first()
-----------------------------------------

Sincerely,
Dmitry Dvoinikov
http://www.targeted.org/


More information about the pybsddb mailing list