Understanding TDB behavior

Amitay Isaacs amitay at gmail.com
Thu Jul 16 07:39:17 UTC 2015


Hi,

Recently I noticed an unexpected (at least to me) behavior in TDB.

One process has created a database without mutex support and is still
running.
Second process tries to open the same database with mutex support.

My expectation was that the tdb_open() in the second process should fail.
But, the second process succeeds and converts the database to use mutexes.

Is this expected?

To check this exhaustively, I wrote a new tdb test (attached) that tries
various create and open flags combinations.  And as a result here are the
findings:

1. Either TDB_ALLOW_NESTING or TDB_DISALLOW_NESTING is always set for
create and open.

2. Create and open with TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST always adds
TDB_INCOMPATIBLE_HASH.

3. Database created with TDB_MUTEX_LOCKING can only be opened without
TDB_MUTEX_LOCKING provided TDB_NOLOCK is specified, otherwise fails with
EINVAL.

4. Open with TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST always converts the
existing database to use mutexes and incompatible hash.

The last finding is really surprising.  I expected that it would fail with
EINVAL.

Is this by design or is this a bug?

Amitay.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-tdb-Add-a-test-to-check-supported-create-open-flags.patch
Type: text/x-patch
Size: 9607 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150716/53b67edc/0001-tdb-Add-a-test-to-check-supported-create-open-flags.bin>


More information about the samba-technical mailing list