From: Amitay Isaacs Date: Thu, 9 Mar 2017 04:50:59 +0000 (+1100) Subject: ctdb-recovery: Delete empty records during recovery X-Git-Tag: tevent-0.9.32~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ebcba49d049fccd1b33b35c8802ec3cf80264ac;p=thirdparty%2Fsamba.git ctdb-recovery: Delete empty records during recovery Persistent databases are now always recovered by sequence number. So there is no need to keep the empty records in the database since they will never be recovered record-by-record using RSN. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Sat Jun 17 16:47:55 CEST 2017 on sn-devel-144 --- diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c index ab5dccc0fa0..b882da0a134 100644 --- a/ctdb/server/ctdb_recovery_helper.c +++ b/ctdb/server/ctdb_recovery_helper.c @@ -220,37 +220,8 @@ static int recbuf_filter_add(struct ctdb_rec_buffer *recbuf, bool persistent, struct ctdb_ltdb_header *header; int ret; - /* - * skip empty records - but NOT for persistent databases: - * - * The record-by-record mode of recovery deletes empty records. - * For persistent databases, this can lead to data corruption - * by deleting records that should be there: - * - * - Assume the cluster has been running for a while. - * - * - A record R in a persistent database has been created and - * deleted a couple of times, the last operation being deletion, - * leaving an empty record with a high RSN, say 10. - * - * - Now a node N is turned off. - * - * - This leaves the local database copy of D on N with the empty - * copy of R and RSN 10. On all other nodes, the recovery has deleted - * the copy of record R. - * - * - Now the record is created again while node N is turned off. - * This creates R with RSN = 1 on all nodes except for N. - * - * - Now node N is turned on again. The following recovery will chose - * the older empty copy of R due to RSN 10 > RSN 1. - * - * ==> Hence the record is gone after the recovery. - * - * On databases like Samba's registry, this can damage the higher-level - * data structures built from the various tdb-level records. - */ - if (!persistent && data.dsize <= sizeof(struct ctdb_ltdb_header)) { + /* Skip empty records */ + if (data.dsize <= sizeof(struct ctdb_ltdb_header)) { return 0; }