r10421: following on discussions with simo, I have worked out a way of
authorAndrew Tridgell <tridge@samba.org>
Thu, 22 Sep 2005 13:12:46 +0000 (13:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:38:44 +0000 (13:38 -0500)
commit7dd31288a701d772e45b1960ac4ce4cc1be782ed
tree868a049e94ccf1fcdbd05f263e920c1c0d87bd24
parent749b19d34f6105c696a07cc2cd39d5acecfc735b
r10421: following on discussions with simo, I have worked out a way of
allowing searches to proceed while another process is in a
transaction, then only upgrading the transaction lock to a write lock
on commit.

The solution is:

 - split tdb_traverse() into two calls, called tdb_traverse() and
   tdb_traverse_read(). The _read() version only gets read locks, and
   will fail any write operations made in the callback from the
   traverse.

 - the normal tdb_traverse() call allows for read or write operations
   in the callback, but gets the transaction lock, preventing
   transastions from starting inside the traverse

In addition we enforce the following rule that you may not start a
transaction within a traverse callback, although you can start a
traverse within a transaction

With these rules in place I believe all the deadlock possibilities are
removed, and we can now allow for searches to happen in parallel with
transactions
source/lib/tdb/common/error.c
source/lib/tdb/common/io.c
source/lib/tdb/common/lock.c
source/lib/tdb/common/tdb.c
source/lib/tdb/common/tdb_private.h
source/lib/tdb/common/transaction.c
source/lib/tdb/common/traverse.c
source/lib/tdb/docs/README
source/lib/tdb/include/tdb.h
source/lib/tdb/tools/tdbtorture.c