From f42486e8912eee45eb75d27b753bb74c3b37d80b Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 20 Aug 2018 15:01:50 +1000 Subject: [PATCH] ctdb-config: Switch tunable TDBMutexEnabled to a config option Use the "database:tdb mutexes" option instead. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13589 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/common/tunable.c | 2 +- ctdb/database/database_conf.c | 21 ++++++++++++++++++++ ctdb/database/database_conf.h | 3 ++- ctdb/doc/ctdb-tunables.7.xml | 11 ---------- ctdb/doc/ctdb.1.xml | 1 - ctdb/doc/ctdb.conf.5.xml | 17 ++++++++++++++++ ctdb/server/ctdb_config.c | 4 ++++ ctdb/server/ctdb_config.h | 1 + ctdb/server/ctdb_ltdb_server.c | 7 +++++-- ctdb/tests/cunit/config_test_001.sh | 1 + ctdb/tests/eventscripts/00.ctdb.setup.002.sh | 2 -- ctdb/tests/eventscripts/scripts/00.ctdb.sh | 1 - ctdb/tests/tool/ctdb.listvars.001.sh | 1 - 13 files changed, 52 insertions(+), 20 deletions(-) diff --git a/ctdb/common/tunable.c b/ctdb/common/tunable.c index 4c1714cee2d..e9367980753 100644 --- a/ctdb/common/tunable.c +++ b/ctdb/common/tunable.c @@ -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) }, diff --git a/ctdb/database/database_conf.c b/ctdb/database/database_conf.c index 0333ce0a0a5..6bdb372bf03 100644 --- a/ctdb/database/database_conf.c +++ b/ctdb/database/database_conf.c @@ -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); } diff --git a/ctdb/database/database_conf.h b/ctdb/database/database_conf.h index 4891b0053b6..6fa579c1502 100644 --- a/ctdb/database/database_conf.h +++ b/ctdb/database/database_conf.h @@ -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); diff --git a/ctdb/doc/ctdb-tunables.7.xml b/ctdb/doc/ctdb-tunables.7.xml index a925ca5ab1f..db3dd209760 100644 --- a/ctdb/doc/ctdb-tunables.7.xml +++ b/ctdb/doc/ctdb-tunables.7.xml @@ -660,17 +660,6 @@ MonitorInterval=20 - - TDBMutexEnabled - Default: 1 - - 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. - - - TickleUpdateInterval Default: 20 diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml index 5c3ce410c0c..da699ff89f0 100644 --- a/ctdb/doc/ctdb.1.xml +++ b/ctdb/doc/ctdb.1.xml @@ -828,7 +828,6 @@ DBRecordCountWarn = 100000 DBRecordSizeWarn = 10000000 DBSizeWarn = 100000000 PullDBPreallocation = 10485760 -TDBMutexEnabled = 1 LockProcessesPerDB = 200 RecBufferSizeLimit = 1000000 QueueBufferSize = 1024 diff --git a/ctdb/doc/ctdb.conf.5.xml b/ctdb/doc/ctdb.conf.5.xml index 840d46d86a3..316ac7f469d 100644 --- a/ctdb/doc/ctdb.conf.5.xml +++ b/ctdb/doc/ctdb.conf.5.xml @@ -304,6 +304,23 @@ + + tdb mutexes = true|false + + + 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. + + + If robust mutexes are unreliable on the platform being + used then they can be disabled by setting this to + false. + + + + lock debug script = FILENAME diff --git a/ctdb/server/ctdb_config.c b/ctdb/server/ctdb_config.c index 1254a996b3b..f00c3268085 100644 --- a/ctdb/server/ctdb_config.c +++ b/ctdb/server/ctdb_config.c @@ -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 diff --git a/ctdb/server/ctdb_config.h b/ctdb/server/ctdb_config.h index 1c06e83f6c7..65c6547258d 100644 --- a/ctdb/server/ctdb_config.h +++ b/ctdb/server/ctdb_config.h @@ -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; diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index f3f7df97ac6..2d1daafb157 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -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, diff --git a/ctdb/tests/cunit/config_test_001.sh b/ctdb/tests/cunit/config_test_001.sh index 27e88888270..74686cac9b9 100755 --- a/ctdb/tests/cunit/config_test_001.sh +++ b/ctdb/tests/cunit/config_test_001.sh @@ -40,6 +40,7 @@ ok <