ctdb_ltdb_store_server: honour the AUTOMATIC record flag
authorMichael Adam <obnox@samba.org>
Thu, 3 Feb 2011 15:32:23 +0000 (16:32 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 9 Mar 2011 23:56:35 +0000 (00:56 +0100)
Do not delete empty records that carry this flag but store
them and schedule them for deletetion. Do not store the flag
in the ltdb though, since this is internal only and should not
be visible to the client.

server/ctdb_ltdb_server.c

index 94c32bd298f91de63ff70c6882a4a732184c20c9..3cf5cfc18fc63214946e10001bb8ebfa2e6a2871 100644 (file)
@@ -102,6 +102,17 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
                keep = true;
        } else if (ctdb_db->persistent) {
                keep = true;
+       } else if (header->flags & CTDB_REC_FLAG_AUTOMATIC) {
+               /*
+                * The record is not created by the client but
+                * automatically by the ctdb_ltdb_fetch logic that
+                * creates a record with an initial header in the
+                * ltdb before trying to migrate the record from
+                * the current lmaster. Keep it instead of trying
+                * to delete the non-existing record...
+                */
+               keep = true;
+               schedule_for_deletion = true;
        } else if (header->flags & CTDB_REC_FLAG_MIGRATED_WITH_DATA) {
                keep = true;
        } else if (ctdb_db->ctdb->pnn == lmaster) {
@@ -157,6 +168,14 @@ store:
         */
        header->flags &= ~CTDB_REC_FLAG_VACUUM_MIGRATED;
 
+       /*
+        * Similarly, clear the AUTOMATIC flag which should not enter
+        * the local database copy since this would require client
+        * modifications to clear the flag when the client stores
+        * the record.
+        */
+       header->flags &= ~CTDB_REC_FLAG_AUTOMATIC;
+
        rec.dsize = sizeof(*header) + data.dsize;
        rec.dptr = talloc_size(ctdb, rec.dsize);
        CTDB_NO_MEMORY(ctdb, rec.dptr);