tdb: Remove locking from tdb_traverse_read()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 31 Mar 2017 04:34:13 +0000 (17:34 +1300)
committerStefan Metzmacher <metze@samba.org>
Sun, 2 Jul 2017 15:35:18 +0000 (17:35 +0200)
commitf80076fe43f18404575cb9ac86ecfc637127c4ba
tree2debcbea0387cd9f8096a5eec52dcc3e133d4c2a
parentb87af322d5fea8bd8280057996ce542c999bcaef
tdb: Remove locking from tdb_traverse_read()

This restores the original intent of tdb_traverse_read() in
7dd31288a701d772e45b1960ac4ce4cc1be782ed

This is needed to avoid a deadlock with tdb_lockall() and the
transaction start, as ldb_tdb should take the allrecord lock during a
search (which calls tdb_traverse), and can otherwise deadlock against
a transaction starting in another process

We add a test to show that a transaction can now start while a read
traverse is in progress

This allows more operations to happen in parallel.  The blocking point
is moved to the prepare commit.

This in turn permits a roughly doubling of unindexed search
performance, because currently ldb_tdb omits to take the lock due to
an unrelated bug, but taking the allrecord lock triggers the
above-mentioned deadlock.

This behaviour was added in 251aaafe3a9213118ac3a92def9ab2104c40d12a for
Solaris 10 in 2005. But the run-fcntl-deadlock test works also on Solaris 10,
see https://lists.samba.org/archive/samba-technical/2017-April/119876.html.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/common/traverse.c
lib/tdb/test/run-nested-traverse.c