ctdb and tombstones in persistent dbs

Ralph Böhme slow at samba.org
Mon May 21 11:02:37 UTC 2018


On Mon, May 21, 2018 at 12:44:21PM +1000, Amitay Isaacs wrote:
> On Mon, May 21, 2018 at 3:16 AM, Ralph Böhme via samba-technical
> <samba-technical at lists.samba.org> wrote:
> > Hi folks,
> >
> > I just noticed that we don't delete records in the *persistent* dbs, but instead
> > store tombstones (empty records). Is there any reason for this?
> 
> Yes, for historic reasons we did not delete empty records from
> persistent db.  Nowadays there is no real need to keep empty records
> in persistent databases.

ok, glad to hear that. :)

> Currently those records get removed only during recovery (commit
> 6ebcba49d049fccd1b33b35c8802ec3cf80264ac).
> 
> > When using persistent dbs for persistent handles, I get lots of tombstones in
> > the persistent locking and smbXsrv_open_global dbs quite fast.
> 
> We can definitely remove the empty records as part of the transaction.
> Since we didn't collect too many empty records in persistent databases
> till now, there hasn't been any need for deleting those records at
> transaction time.  The empty records would get purged at database
> recovery and that was sufficient.  Also, the code where this change is
> required is hairy and unless there was a need for it, I didn't want to
> touch that code. :-)

I tried it myself, cf the attached patch but that ended up in a disaster. :)
Somehow the deletion triggered a ctdb recovery, so I gave up on it for now.

-slow

-- 
Ralph Boehme, Samba Team       https://samba.org/
Samba Developer, SerNet GmbH   https://sernet.de/en/samba/
GPG Key Fingerprint:           FAE2 C608 8A24 2520 51C5
                               59E4 AA1E 9B71 2639 9E46
-------------- next part --------------
From ff008be029f0db1a137bd8ec837cb6ce2257c110 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 20 May 2018 18:48:46 +0200
Subject: [PATCH] WRONG?: ctdb: don't store tombstones in persistent dbs

---
 ctdb/common/ctdb_ltdb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c
index 79b62b79cd3..a7af03dcf85 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -313,7 +313,11 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
 			free(old.dptr);
 		}
 	}
-	ret = tdb_storev(ctdb_db->ltdb->tdb, key, rec, 2, TDB_REPLACE);
+        if (data.dsize > 0) {
+                ret = tdb_storev(ctdb_db->ltdb->tdb, key, rec, 2, TDB_REPLACE);
+        } else {
+                ret = tdb_delete(ctdb_db->ltdb->tdb, key);
+        }
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Failed to store dynamic data\n"));
 	}
-- 
2.13.6



More information about the samba-technical mailing list