From: Martin Schwenke Date: Mon, 10 Jan 2022 08:18:14 +0000 (+1100) Subject: ctdb-config: [cluster] recovery lock -> [cluster] cluster lock X-Git-Tag: tdb-1.4.6~96 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f5a39058f0743f5607df91cb698a2b15618e1360;p=thirdparty%2Fsamba.git ctdb-config: [cluster] recovery lock -> [cluster] cluster lock Retain "recovery lock" and mark as deprecated for backward compatibility. Some documentation is still inconsistent. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/cluster/cluster_conf.c b/ctdb/cluster/cluster_conf.c index be79d5942a8..3b86bad80ef 100644 --- a/ctdb/cluster/cluster_conf.c +++ b/ctdb/cluster/cluster_conf.c @@ -113,6 +113,24 @@ good: mode); } +static bool validate_recovery_lock(const char *key, + const char *old_reclock, + const char *new_reclock, + enum conf_update_mode mode) +{ + bool status; + + if (new_reclock != NULL) { + D_WARNING("Configuration option [%s] -> %s is deprecated\n", + CLUSTER_CONF_SECTION, + key); + } + + status = check_static_string_change(key, old_reclock, new_reclock, mode); + + return status; +} + void cluster_conf_init(struct conf_context *conf) { conf_define_section(conf, CLUSTER_CONF_SECTION, NULL); @@ -129,7 +147,12 @@ void cluster_conf_init(struct conf_context *conf) validate_node_address); conf_define_string(conf, CLUSTER_CONF_SECTION, - CLUSTER_CONF_RECOVERY_LOCK, + CLUSTER_CONF_CLUSTER_LOCK, NULL, check_static_string_change); + conf_define_string(conf, + CLUSTER_CONF_SECTION, + CLUSTER_CONF_RECOVERY_LOCK, + NULL, + validate_recovery_lock); } diff --git a/ctdb/cluster/cluster_conf.h b/ctdb/cluster/cluster_conf.h index 6b797ef1085..cdd42e15b7d 100644 --- a/ctdb/cluster/cluster_conf.h +++ b/ctdb/cluster/cluster_conf.h @@ -26,6 +26,7 @@ #define CLUSTER_CONF_TRANSPORT "transport" #define CLUSTER_CONF_NODE_ADDRESS "node address" +#define CLUSTER_CONF_CLUSTER_LOCK "cluster lock" #define CLUSTER_CONF_RECOVERY_LOCK "recovery lock" void cluster_conf_init(struct conf_context *conf); diff --git a/ctdb/config/ctdb.conf b/ctdb/config/ctdb.conf index 5440600a435..8e1b3760973 100644 --- a/ctdb/config/ctdb.conf +++ b/ctdb/config/ctdb.conf @@ -11,12 +11,12 @@ # log level = NOTICE [cluster] - # Shared recovery lock file to avoid split brain. Daemon - # default is no recovery lock. Do NOT run CTDB without a - # recovery lock file unless you know exactly what you are + # Shared cluster lock file to avoid split brain. Daemon + # default is no cluster lock. Do NOT run CTDB without a + # cluster lock file unless you know exactly what you are # doing. # - # Please see the RECOVERY LOCK section in ctdb(7) for more + # Please see the CLUSTER LOCK section in ctdb(7) for more # details. # - # recovery lock = !/bin/false RECOVERY LOCK NOT CONFIGURED + # cluster lock = !/bin/false CLUSTER LOCK NOT CONFIGURED diff --git a/ctdb/doc/cluster_mutex_helper.txt b/ctdb/doc/cluster_mutex_helper.txt index 20c8eb2b51d..4ee018ffc94 100644 --- a/ctdb/doc/cluster_mutex_helper.txt +++ b/ctdb/doc/cluster_mutex_helper.txt @@ -5,11 +5,11 @@ CTDB uses cluster-wide mutexes to protect against a "split brain", which could occur if the cluster becomes partitioned due to network failure or similar. -CTDB uses a cluster-wide mutex for its "recovery lock", which is used +CTDB uses a cluster-wide mutex for its "cluster lock", which is used to ensure that only one database recovery can happen at a time. For -an overview of recovery lock configuration see the RECOVERY LOCK +an overview of cluster lock configuration see the CLUSTER LOCK section in ctdb(7). CTDB tries to ensure correct operation of the -recovery lock by attempting to take the recovery lock when CTDB knows +cluster lock by attempting to take the cluster lock when CTDB knows that it should already be held. By default, CTDB uses a supplied mutex helper that uses a fcntl(2) diff --git a/ctdb/doc/ctdb-etcd.7.xml b/ctdb/doc/ctdb-etcd.7.xml index 5d7a0e05366..f84989f854f 100644 --- a/ctdb/doc/ctdb-etcd.7.xml +++ b/ctdb/doc/ctdb-etcd.7.xml @@ -60,7 +60,7 @@ ctdb_etcd_lock is intended to be run as a mutex helper for CTDB. It will try to connect to an existing etcd cluster and grab a lock in that - cluster to function as CTDB's recovery lock. Please see + cluster to function as CTDB's cluster lock. Please see ctdb/doc/cluster_mutex_helper.txt for details on the mutex helper API. To use this, include the following line in the [cluster] section of @@ -68,7 +68,7 @@ 5: -recovery lock = !/usr/local/usr/libexec/ctdb/ctdb_etcd_lock +cluster lock = !/usr/local/usr/libexec/ctdb/ctdb_etcd_lock You can also pass "-v", "-vv", or "-vvv" to include verbose output in diff --git a/ctdb/doc/ctdb.conf.5.xml b/ctdb/doc/ctdb.conf.5.xml index f4ef9599d9c..910ac4102f6 100644 --- a/ctdb/doc/ctdb.conf.5.xml +++ b/ctdb/doc/ctdb.conf.5.xml @@ -175,20 +175,20 @@ - recovery lock = LOCK + cluster lock = LOCK LOCK specifies the cluster-wide mutex used to detect and prevent a partitioned cluster (or "split brain"). - For information about the recovery lock please see the - RECOVERY LOCK section in + For information about the cluster lock please see the + CLUSTER LOCK section in ctdb 7. - Default: NONE. However, uses of a recovery lock is + Default: NONE. However, uses of a cluster lock is strongly recommended. diff --git a/ctdb/doc/ctdb_mutex_ceph_rados_helper.7.xml b/ctdb/doc/ctdb_mutex_ceph_rados_helper.7.xml index e055dbba614..dd3dbabdd50 100644 --- a/ctdb/doc/ctdb_mutex_ceph_rados_helper.7.xml +++ b/ctdb/doc/ctdb_mutex_ceph_rados_helper.7.xml @@ -19,7 +19,7 @@ DESCRIPTION - ctdb_mutex_ceph_rados_helper can be used as a recovery lock provider + ctdb_mutex_ceph_rados_helper can be used as a cluster lock provider for CTDB. When configured, split brain avoidance during CTDB recovery will be handled using locks against an object located in a Ceph RADOS pool. @@ -29,7 +29,7 @@ 5: -recovery lock = !ctdb_mutex_ceph_rados_helper [Cluster] [User] [Pool] [Object] +cluster lock = !ctdb_mutex_ceph_rados_helper [Cluster] [User] [Pool] [Object] Cluster: Ceph cluster name (e.g. ceph) User: Ceph cluster user name (e.g. client.admin) @@ -44,7 +44,7 @@ Object: Ceph RADOS object name For informational purposes, ctdb_mutex_ceph_rados_helper will also - register the recovery lock holder in Ceph Manager's service map. + register the cluster lock holder in Ceph Manager's service map. diff --git a/ctdb/doc/examples/ctdb.conf b/ctdb/doc/examples/ctdb.conf index fa5e8f7894c..3a8ccc658b8 100644 --- a/ctdb/doc/examples/ctdb.conf +++ b/ctdb/doc/examples/ctdb.conf @@ -47,7 +47,7 @@ log level = NOTICE [cluster] - recovery lock = /shared/recovery.lock + cluster lock = /shared/cluster.lock # # Nodes configuration diff --git a/ctdb/server/ctdb_config.c b/ctdb/server/ctdb_config.c index 750b909cd3d..17e697996ab 100644 --- a/ctdb/server/ctdb_config.c +++ b/ctdb/server/ctdb_config.c @@ -49,6 +49,10 @@ static void setup_config_pointers(struct conf_context *conf) CLUSTER_CONF_SECTION, CLUSTER_CONF_NODE_ADDRESS, &ctdb_config.node_address); + conf_assign_string_pointer(conf, + CLUSTER_CONF_SECTION, + CLUSTER_CONF_CLUSTER_LOCK, + &ctdb_config.cluster_lock); conf_assign_string_pointer(conf, CLUSTER_CONF_SECTION, CLUSTER_CONF_RECOVERY_LOCK, diff --git a/ctdb/server/ctdb_config.h b/ctdb/server/ctdb_config.h index f2f75972661..f079d495445 100644 --- a/ctdb/server/ctdb_config.h +++ b/ctdb/server/ctdb_config.h @@ -26,6 +26,7 @@ struct ctdb_config { /* Cluster */ const char *transport; const char *node_address; + const char *cluster_lock; const char *recovery_lock; /* Database */ diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 72d811f1c8f..e333d7cb7cb 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -282,10 +282,13 @@ int main(int argc, const char *argv[]) goto fail; } - if (ctdb_config.recovery_lock == NULL) { - D_WARNING("Recovery lock not set\n"); + if (ctdb_config.cluster_lock != NULL) { + ctdb->recovery_lock = ctdb_config.cluster_lock; + } else if (ctdb_config.recovery_lock != NULL) { + ctdb->recovery_lock = ctdb_config.recovery_lock; + } else { + D_WARNING("Cluster lock not set\n"); } - ctdb->recovery_lock = ctdb_config.recovery_lock; /* tell ctdb what address to listen on */ if (ctdb_config.node_address) { diff --git a/ctdb/tests/UNIT/cunit/config_test_001.sh b/ctdb/tests/UNIT/cunit/config_test_001.sh index 9a8682b04e6..b4a64ab790c 100755 --- a/ctdb/tests/UNIT/cunit/config_test_001.sh +++ b/ctdb/tests/UNIT/cunit/config_test_001.sh @@ -34,6 +34,7 @@ ok < "$conffile" < "$conffile" < "$conffile" < recovery lock is deprecated +EOF +unit_test ctdb-config -d WARNING validate diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh index 626cc192876..c75a554c548 100755 --- a/ctdb/tests/local_daemons.sh +++ b/ctdb/tests/local_daemons.sh @@ -127,7 +127,7 @@ Options: -N Nodes file (default: automatically generated) -n Number of nodes (default: 3) -P Public addresses file (default: automatically generated) - -R Use a command for the recovery lock (default: use a file) + -R Use a command for the cluster lock (default: use a file) -r