[RFC] Use mutexes by default in db_open()

Amitay Isaacs amitay at gmail.com
Mon May 29 02:21:50 UTC 2017

On Wed, May 24, 2017 at 3:10 PM, Ralph Böhme <slow at samba.org> wrote:

> Hi Amitay,
> On Wed, May 24, 2017 at 11:59:46AM +1000, Amitay Isaacs wrote:
> > Will this also happen for clustered samba case?
> yes, by passing TDB_MUTEX_LOCKING based on smb.conf setting. Just the
> smb.conf
> setting default would be changed (dbwrap_tdb_mutexes:*=true|false,
> default:
> true).

> > In that case, CTDB should
> > also default to using mutexes.
> >
> > Currently CTDB will attach with mutexes option only if
> >   - CTDB tunable TDBMutexEnabled is set to 1, and
> >   - Samba passes TDB_MUTEX_LOCKING flag to DB_ATTACH control
> >
> > I would like to get rid of the need for clients to specify tdb_flags to
> > DB_ATTACH control.  As the tdb_flags are really determined by the
> database
> > model which is dictated by the attach control (DB_ATTACH or
> How would that work with the way we determine the setting based on runtime
> settings from smb.conf? Code: <https://goo.gl/MTMKOO>
For clustered samba, currently the decision whether to use mutexes is
decided not just by dbwrap_tdb_mutexes setting in samba configuration, but
also TDBMutexEnabled tunable in ctdb.  Only when both the configuration
options are enabled (and of course if robust mutexes are supported), ctdb
will enable TDB_MUTEX_LOCKING flag for volatile databases.  So just relying
on samba configuration option is anyway incomplete for clustered samba case.

In CTDB, there are clearly defined database models (volatile and
persistent) with specific tdb flags. You can't really override those flags
from samba with the exception of TDB_MUTEX_LOCKING.  To make things simpler
I would like to propose that we should use ctdb tunable for controlling
whether mutexes are enabled. In cluster samba case, ctdb is always the
first opener for clustered databases anyway.

I have been working on a patch set that removes tdb_flags calculation
spread all over ctdb to a single location.  This ensures that the flags get
defined by the database model are clearly seen.  As discovered at SambaXP,
for distributed database model (new model to be introduced soon), using
mutexes is actually bad.  In such a case, there is no point to allow ctdb
clients to specify tdb_flags to DB_ATTACH controls since they will be
ignored anyway.

Here's the summary of what I would like to propose:
 1. CTDB ignores tdb_flags specified in DB_ATTACH controls, tdb flags are
calculated based on the database model (or specific DB_ATTACH control)
 2. For volatile databases, mutexes will be enabled by default
(TDBMutexEnabled=1) when samba enables mutexes by default

As a result, in clustered samba case, dbwrap_tdb_mutexes settings will be
ignored for clustered (volatile) databases.


More information about the samba-technical mailing list