ctdb-config: Switch tunable TDBMutexEnabled to a config option
authorMartin Schwenke <martin@meltin.net>
Mon, 20 Aug 2018 05:01:50 +0000 (15:01 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 24 Aug 2018 08:59:21 +0000 (10:59 +0200)
Use the "database:tdb mutexes" option instead.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
13 files changed:
ctdb/common/tunable.c
ctdb/database/database_conf.c
ctdb/database/database_conf.h
ctdb/doc/ctdb-tunables.7.xml
ctdb/doc/ctdb.1.xml
ctdb/doc/ctdb.conf.5.xml
ctdb/server/ctdb_config.c
ctdb/server/ctdb_config.h
ctdb/server/ctdb_ltdb_server.c
ctdb/tests/cunit/config_test_001.sh
ctdb/tests/eventscripts/00.ctdb.setup.002.sh
ctdb/tests/eventscripts/scripts/00.ctdb.sh
ctdb/tests/tool/ctdb.listvars.001.sh

index 4c1714c..e936798 100644 (file)
@@ -145,7 +145,7 @@ static struct {
                offsetof(struct ctdb_tunable_list, no_ip_host_on_all_disabled) },
        { "Samba3AvoidDeadlocks", 0, true,
                offsetof(struct ctdb_tunable_list, samba3_hack) },
-       { "TDBMutexEnabled", 1, false,
+       { "TDBMutexEnabled", 1, true,
                offsetof(struct ctdb_tunable_list, mutex_enabled) },
        { "LockProcessesPerDB", 200, false,
                offsetof(struct ctdb_tunable_list, lock_processes_per_db) },
index 0333ce0..6bdb372 100644 (file)
@@ -54,6 +54,22 @@ static bool check_static_string_change(const char *key,
        return true;
 }
 
+static bool check_static_boolean_change(const char *key,
+                                       bool old_value,
+                                       bool new_value,
+                                       enum conf_update_mode mode)
+{
+       if (mode == CONF_MODE_RELOAD || CONF_MODE_API) {
+               if (old_value != new_value) {
+                       D_WARNING("Ignoring update of [%s] -> %s\n",
+                                 DATABASE_CONF_SECTION,
+                                 key);
+               }
+       }
+
+       return true;
+}
+
 static bool database_conf_validate_lock_debug_script(const char *key,
                                                     const char *old_script,
                                                     const char *new_script,
@@ -141,4 +157,9 @@ void database_conf_init(struct conf_context *conf)
                           DATABASE_CONF_LOCK_DEBUG_SCRIPT,
                           NULL,
                           database_conf_validate_lock_debug_script);
+       conf_define_boolean(conf,
+                           DATABASE_CONF_SECTION,
+                           DATABASE_CONF_TDB_MUTEXES,
+                           true,
+                           check_static_boolean_change);
 }
index 4891b00..6fa579c 100644 (file)
@@ -27,7 +27,8 @@
 #define DATABASE_CONF_VOLATILE_DB_DIR           "volatile database directory"
 #define DATABASE_CONF_PERSISTENT_DB_DIR         "persistent database directory"
 #define DATABASE_CONF_STATE_DB_DIR              "state database directory"
-#define DATABASE_CONF_LOCK_DEBUG_SCRIPT          "lock debug script"
+#define DATABASE_CONF_LOCK_DEBUG_SCRIPT         "lock debug script"
+#define DATABASE_CONF_TDB_MUTEXES               "tdb mutexes"
 
 void database_conf_init(struct conf_context *conf);
 
index a925ca5..db3dd20 100644 (file)
@@ -660,17 +660,6 @@ MonitorInterval=20
       </para>
     </refsect2>
 
-    <refsect2>
-      <title>TDBMutexEnabled</title>
-      <para>Default: 1</para>
-      <para>
-       This parameter enables TDB_MUTEX_LOCKING feature on volatile
-       databases if the robust mutexes are supported. This optimizes the
-       record locking using robust mutexes and is much more efficient
-       that using posix locks.
-      </para>
-    </refsect2>
-
     <refsect2>
       <title>TickleUpdateInterval</title>
       <para>Default: 20</para>
index 5c3ce41..da699ff 100644 (file)
@@ -828,7 +828,6 @@ DBRecordCountWarn       = 100000
 DBRecordSizeWarn        = 10000000
 DBSizeWarn              = 100000000
 PullDBPreallocation     = 10485760
-TDBMutexEnabled         = 1
 LockProcessesPerDB      = 200
 RecBufferSizeLimit      = 1000000
 QueueBufferSize         = 1024
index 840d46d..316ac7f 100644 (file)
        </listitem>
       </varlistentry>
 
+      <varlistentry>
+       <term>tdb mutexes = true|false</term>
+       <listitem>
+         <para>
+           This parameter enables TDB_MUTEX_LOCKING feature on
+           volatile databases if the robust mutexes are
+           supported. This optimizes the record locking using robust
+           mutexes and is much more efficient that using posix locks.
+         </para>
+         <para>
+           If robust mutexes are unreliable on the platform being
+           used then they can be disabled by setting this to
+           <literal>false</literal>.
+         </para>
+       </listitem>
+      </varlistentry>
+
       <varlistentry>
        <term>lock debug script = <parameter>FILENAME</parameter></term>
        <listitem>
index 1254a99..f00c326 100644 (file)
@@ -73,6 +73,10 @@ static void setup_config_pointers(struct conf_context *conf)
                                   DATABASE_CONF_SECTION,
                                   DATABASE_CONF_LOCK_DEBUG_SCRIPT,
                                   &ctdb_config.lock_debug_script);
+       conf_assign_boolean_pointer(conf,
+                                   DATABASE_CONF_SECTION,
+                                   DATABASE_CONF_TDB_MUTEXES,
+                                   &ctdb_config.tdb_mutexes);
 
        /*
         * Event
index 1c06e83..65c6547 100644 (file)
@@ -33,6 +33,7 @@ struct ctdb_config {
        const char *dbdir_persistent;
        const char *dbdir_state;
        const char *lock_debug_script;
+       bool tdb_mutexes;
 
        /* Event */
        const char *event_debug_script;
index f3f7df9..2d1daaf 100644 (file)
@@ -41,6 +41,8 @@
 #include "common/common.h"
 #include "common/logging.h"
 
+#include "server/ctdb_config.h"
+
 #define PERSISTENT_HEALTH_TDB "persistent_health.tdb"
 
 /**
@@ -846,8 +848,9 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name,
                                                ctdb->db_directory,
                                           db_name, ctdb->pnn);
 
-       tdb_flags = ctdb_db_tdb_flags(db_flags, ctdb->valgrinding,
-                                     ctdb->tunable.mutex_enabled);
+       tdb_flags = ctdb_db_tdb_flags(db_flags,
+                                     ctdb->valgrinding,
+                                     ctdb_config.tdb_mutexes);
 
 again:
        ctdb_db->ltdb = tdb_wrap_open(ctdb_db, ctdb_db->db_path,
index 27e8888..74686ca 100755 (executable)
@@ -40,6 +40,7 @@ ok <<EOF
        # persistent database directory = ${database_persistent_dbdir}
        # state database directory = ${database_state_dbdir}
        # lock debug script = 
+       # tdb mutexes = true
 [event]
        # debug script = 
 [legacy]
index fc1ec76..10bddea 100755 (executable)
@@ -8,12 +8,10 @@ setup
 
 setup_tunable_config <<EOF
 MonitorInterval=5
-TDBMutexEnabled=0
 EOF
 
 required_result 0 <<EOF
 Set MonitorInterval to 5
-Set TDBMutexEnabled to 0
 EOF
 
 simple_test
index 5f169e6..7925679 100644 (file)
@@ -8,7 +8,6 @@ setup ()
 
        export FAKE_CTDB_TUNABLES_OK="
               MonitorInterval
-              TDBMutexEnabled
               DatabaseHashSize
               "
        export FAKE_CTDB_TUNABLES_OBSOLETE="
index e9fb686..95b6c31 100755 (executable)
@@ -58,7 +58,6 @@ DBRecordCountWarn          = 100000
 DBRecordSizeWarn           = 10000000
 DBSizeWarn                 = 100000000
 PullDBPreallocation        = 10485760
-TDBMutexEnabled            = 1
 LockProcessesPerDB         = 200
 RecBufferSizeLimit         = 1000000
 QueueBufferSize            = 1024