Bugfix for tdb transactions

tridge at samba.org tridge at samba.org
Sun Jan 31 02:10:20 MST 2010

Hi Volker and Michael,

 > Attached find a patch by Michael Adam that fixes a bug in
 > the tdb transaction code. Michael was just faster doing the
 > patch after I showed him the problem after about 20 hours of
 > very intensive and exhausting debugging :-)

I think you've found a real bug, but I think the fix needs a little
bit more work. The use of tdb->transaction->prepared as the flag to
say if the GLOBAL_LOCK is held won't work if the transaction needs to
expand the recovery area.

The problem is that transaction_setup_recovery() called after
tdb->transaction->prepared is set to true calls
tdb_recovery_allocate() that calls a write method, which then gets
refused as 'prepared' is set to true (see the check in
transaction_write() which refuses writes on a prepared transaction).

I think if you leave the tdb->transaction->prepared boolean alone, and
instead add a new bool to the transaction structure that gets set when
the GLOBAL_LOCK is taken then the patch will be good.

(make test finds the above problem pretty quickly in s4, so it would
be worth testing that. tdbtorture also finds it.).

Thanks for finding the bug! I can imagine that this was not an easy
one to find :-)

Cheers, Tridge

More information about the samba-technical mailing list