tdb: Do not return errors from tdb_repack() in the tail of tdb_transaction_commit()
authorAndrew Bartlett <abartlet@samba.org>
Thu, 16 May 2019 04:14:13 +0000 (16:14 +1200)
committerJeremy Allison <jra@samba.org>
Fri, 17 May 2019 06:48:10 +0000 (06:48 +0000)
commit444b594fd12dbf910bea55cdc2055152cfee2449
tree8451b93b9db3205b2a3d45f85a88e1dcf50ed13d
parentab648a4c63524038c9626a77be243c79c51975ac
tdb: Do not return errors from tdb_repack() in the tail of tdb_transaction_commit()

The call to tdb_repack() inside tdb_transaction_commit()
is an optimization, not part of the transaction itself,
so failing due to lock or other errors isn't a fatal error
that should cause the caller to think the transaction was
a failure by returning -1.

The tdb transaction itself has finished and been committed
onto stable storage via fsync and all locks released at the
point tdb_repack() is called.

tdb_repack() is only called here as it's a convenient point
to attempt to reduce tdb fragmentation without having to add
a timer call to repack in all users of tdb.

This causes lock ordering issues in Samba, showing up as:

ldb: ltdb: tdb(../private/sam.ldb.d/DC=SAMBA2008R2,DC=EXAMPLE,DC=COM.ldb): tdb_transaction_prepare_commit: failed to upgrade hash locks: Locking error

This is because Samba has multiple tdb databases open, and the lock order between them
is important.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13952

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb/common/transaction.c