ctdb-recovery: Delete empty records during recovery
authorAmitay Isaacs <amitay@gmail.com>
Thu, 9 Mar 2017 04:50:59 +0000 (15:50 +1100)
committerMartin Schwenke <martins@samba.org>
Sat, 17 Jun 2017 14:47:55 +0000 (16:47 +0200)
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 <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sat Jun 17 16:47:55 CEST 2017 on sn-devel-144

ctdb/server/ctdb_recovery_helper.c

index ab5dccc0fa038d312c8ef16d12c0c5c8d295e86d..b882da0a134ba9e531553286c1de4f22492c20e3 100644 (file)
@@ -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;
        }