ntdb: fix database corruption when transaction doesn't change anything.
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 17 Feb 2013 10:26:34 +0000 (20:56 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 20 Feb 2013 04:31:19 +0000 (05:31 +0100)
commit3d82f786ecdd6747e90fe480a15de8c3fcea5f7b
tree4197bb0051b0effbae636d7dc559a433647ee428
parent85b6329b91f402da474547410e82438ea2554775
ntdb: fix database corruption when transaction doesn't change anything.

ntdb's transaction code has an optimization which tdb's doesnt: it
only writes the parts of blocks whose contents have changed.  This
means we can actually have a transaction which turns out to need no
recovery region.

This breaks the recovery setup logic, which sets the current recovery
size to 0 if there's no recovery area, and assumes that we'll always
create a new recovery area since the recovery will always need > 0
bytes.

In fact, if we really haven't changed anything, we can skip the
transaction commit altogether: since this happens at least once with
Samba, it's worth doing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ntdb/test/api-60-noop-transaction.c [new file with mode: 0644]
lib/ntdb/transaction.c
lib/ntdb/wscript