[PATCH] Enable TDB mutexes by default in dbwrap and ctdb

Amitay Isaacs amitay at gmail.com
Tue Jul 11 07:03:08 UTC 2017

On Tue, Jul 11, 2017 at 3:20 PM, Volker Lendecke <Volker.Lendecke at sernet.de>

> On Tue, Jul 11, 2017 at 03:40:13AM +1000, Amitay Isaacs via
> samba-technical wrote:
> > I wondered about that.  As far as I can see we don't really use the
> > TDB_SEQNUM feature in CTDB.
> ctdb itself probably doesn't, but dbwrap_ctdb users might depend on
> the sequence number being bumped up if the database changes.
> > Does anyone remember why was it added in the first place?
> >
> > If we don't need the TDB SEQNUM feature, then I can drop it from CTDB.
> It was added in the past for the notify databases, which are gone by
> now. But it's a part of the published TDB API, and it would be a
> surprise to dbwrap users if it did not work for ctdb managed
> databases. Doing a quick grep shows that brlock.tdb uses it. Whether
> that is really strictly needed is something I need to investigate, but
> it's there.

I looked at the logic of updating tdb seqnum cluster-wide and it's ad-hoc.
Since samba can update the record on any node, CTDB has to keep
periodically checking for tdb seqnum changes and then propagate them.

Also, since there is no tdb api to set the seqnum to specific value,
database recovery will reset the seqnum.

Here's the code from brlock.c:

        if (!lp_clustering()) {
                 * We can't use the SEQNUM trick to cache brlock
                 * entries in the clustering case because ctdb seqnum
                 * propagation has a delay.
                tdb_flags |= TDB_SEQNUM;

Looks like we don't rely on seqnum with CTDB.

It looks like seqnum is used to find out if the database has changed or not
to infer if the record has changed or not. May be record sequence number
(RSN) can be used with dbwrap_ctdb.

However, there are no monotonic guarantees on RSN since RSN is reset to 0
when the record gets deleted.  But since the record is tracked for changes
only while it exists, may be RSN could work.


More information about the samba-technical mailing list