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 4c1714cee2df4fae8087f081d014dd920f1e6691..e93679807537f0eadcd8a0000666b52d88643cec 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 0333ce0a0a5f6907b216bb9ddb768952dc249e55..6bdb372bf033dd41a125afbf7d9ec02709a1445d 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 4891b0053b60f20c16f5d39b7adba05c21637360..6fa579c150211e70b56bef025cccde2267f18baa 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 a925ca5ab1f7fb2e2d4fe76df7839aa89de02946..db3dd209760d4ca38faebed62fa5d0f35efecfa8 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 5c3ce410c0c9df33c98f51a70d4df52d58aa5d80..da699ff89f061d6cdc3ecd2a433cfff37bcd598b 100644 (file)
@@ -828,7 +828,6 @@ DBRecordCountWarn       = 100000
 DBRecordSizeWarn        = 10000000
 DBSizeWarn              = 100000000
 PullDBPreallocation     = 10485760
-TDBMutexEnabled         = 1
 LockProcessesPerDB      = 200
 RecBufferSizeLimit      = 1000000
 QueueBufferSize         = 1024
index 840d46d86a3a21b5e4f26b97ad2c042c6eb13ef5..316ac7f469d38a47d8c89bee82042f00ca9c8561 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 1254a996b3b330cba74d585024cedafd59966637..f00c3268085a025b2fc7f5eb8ea09dc75c1abe43 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 1c06e83f6c705dda850cf470019f3634a28d2a08..65c6547258dba3d7126a388e3953581ac0eb5e4e 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 f3f7df97ac67a5aeb52ddf48998435c817df13f6..2d1daafb1575ef208f4b530870aa64d85ecbd1c9 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 27e88888270c4d7617533b4ac18188c7d4adfadb..74686cac9b9ad7751edd5358cde48a09fe4831a8 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 fc1ec76996ab40a3facde66ed0184d3f6bd5ec1b..10bddea1549b236ba0d77d9b87399707e292c6fc 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 5f169e6c6ea3fd2efa13466fde20dd42b5b056da..7925679cc473e2e52b601184781322d66dd8452e 100644 (file)
@@ -8,7 +8,6 @@ setup ()
 
        export FAKE_CTDB_TUNABLES_OK="
               MonitorInterval
-              TDBMutexEnabled
               DatabaseHashSize
               "
        export FAKE_CTDB_TUNABLES_OBSOLETE="
index e9fb686e191aa713a127bddccfc954b72d90a5c6..95b6c3133f9526319339a8e1430acf8e2d3e2dc2 100755 (executable)
@@ -58,7 +58,6 @@ DBRecordCountWarn          = 100000
 DBRecordSizeWarn           = 10000000
 DBSizeWarn                 = 100000000
 PullDBPreallocation        = 10485760
-TDBMutexEnabled            = 1
 LockProcessesPerDB         = 200
 RecBufferSizeLimit         = 1000000
 QueueBufferSize            = 1024