From: Martin Schwenke Date: Sun, 18 May 2025 23:06:38 +0000 (+1000) Subject: ctdb-daemon: Add configuration option shutdown extra timeout X-Git-Tag: samba-4.21.6~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a16697b9b23f962869eacbff128d68833d537d9;p=thirdparty%2Fsamba.git ctdb-daemon: Add configuration option shutdown extra timeout See documentation change for details. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15858 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 3a770c8d46934870f42059640b0aaa0c76a3f4fb) --- diff --git a/ctdb/conf/ctdb_config.c b/ctdb/conf/ctdb_config.c index 03649836e3f..27623a8972a 100644 --- a/ctdb/conf/ctdb_config.c +++ b/ctdb/conf/ctdb_config.c @@ -106,6 +106,10 @@ static void setup_config_pointers(struct conf_context *conf) FAILOVER_CONF_SECTION, FAILOVER_CONF_DISABLED, &ctdb_config.failover_disabled); + conf_assign_integer_pointer(conf, + FAILOVER_CONF_SECTION, + FAILOVER_CONF_SHUTDOWN_EXTRA_TIMEOUT, + &ctdb_config.shutdown_extra_timeout); conf_assign_integer_pointer(conf, FAILOVER_CONF_SECTION, FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT, diff --git a/ctdb/conf/ctdb_config.h b/ctdb/conf/ctdb_config.h index b3ae5a43580..656a99e36bc 100644 --- a/ctdb/conf/ctdb_config.h +++ b/ctdb/conf/ctdb_config.h @@ -43,6 +43,7 @@ struct ctdb_config { /* Failover */ bool failover_disabled; + int shutdown_extra_timeout; int shutdown_failover_timeout; /* Legacy */ diff --git a/ctdb/conf/failover_conf.c b/ctdb/conf/failover_conf.c index 01b0b617827..424021b7a22 100644 --- a/ctdb/conf/failover_conf.c +++ b/ctdb/conf/failover_conf.c @@ -51,6 +51,12 @@ void failover_conf_init(struct conf_context *conf) false, check_static_boolean_change); + conf_define_integer(conf, + FAILOVER_CONF_SECTION, + FAILOVER_CONF_SHUTDOWN_EXTRA_TIMEOUT, + 0, + NULL); + conf_define_integer(conf, FAILOVER_CONF_SECTION, FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT, diff --git a/ctdb/conf/failover_conf.h b/ctdb/conf/failover_conf.h index 34ab9c193b3..08f5fb8939c 100644 --- a/ctdb/conf/failover_conf.h +++ b/ctdb/conf/failover_conf.h @@ -25,6 +25,7 @@ #define FAILOVER_CONF_SECTION "failover" #define FAILOVER_CONF_DISABLED "disabled" +#define FAILOVER_CONF_SHUTDOWN_EXTRA_TIMEOUT "shutdown extra timeout" #define FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT "shutdown failover timeout" diff --git a/ctdb/doc/ctdb.conf.5.xml b/ctdb/doc/ctdb.conf.5.xml index d7d2f5395eb..5b2de2b7a07 100644 --- a/ctdb/doc/ctdb.conf.5.xml +++ b/ctdb/doc/ctdb.conf.5.xml @@ -454,6 +454,37 @@ + + shutdown extra timeout = TIMEOUT + + + CTDB will wait for TIMEOUT seconds after failover + completes during shutdown. This can provide extra time + for SMB durable handles to be reclaimed. If set to 0 then + no extra timeout occurs. + + + This timeout only occurs if both of the following + conditions are true: + + + + + shutdown failover timeout (below) is not 0 + + + + + Failover during shutdown completes and does not time out + + + + + Default: 0 + + + + shutdown failover timeout = TIMEOUT @@ -461,7 +492,8 @@ CTDB will wait for TIMEOUT seconds for failover to complete during shutdown. This allows NFS servers on other nodes to go into grace during graceful shutdown of a - node. + node. Failover during shutdown also helps with SMB + durable handle reclaim. Set this to 0 to disable explicit failover on shutdown. diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 3d07e6e8c3d..1fd646c3758 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -2416,6 +2416,29 @@ done: srvid_deregister(ctdb->srv, CTDB_SRVID_TAKEOVER_RUN, &state); srvid_deregister(ctdb->srv, CTDB_SRVID_LEADER, &state); TALLOC_FREE(state.te); + + if (!state.takeover_done || ctdb_config.shutdown_extra_timeout <= 0) { + return; + } + + state.timed_out = false; + state.te = tevent_add_timer( + ctdb->ev, + ctdb->srv, + timeval_current_ofs(ctdb_config.shutdown_extra_timeout, 0), + shutdown_timeout_handler, + &state); + if (state.te == NULL) { + DBG_WARNING("Failed to set extra timeout\n"); + return; + } + + DBG_NOTICE("Waiting %ds for shutdown extra timeout\n", + ctdb_config.shutdown_extra_timeout); + while (!state.timed_out) { + tevent_loop_once(ctdb->ev); + } + DBG_INFO("shutdown extra timeout complete\n"); } void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code) diff --git a/ctdb/tests/UNIT/cunit/config_test_001.sh b/ctdb/tests/UNIT/cunit/config_test_001.sh index 1cf49a820de..b4d784c65ae 100755 --- a/ctdb/tests/UNIT/cunit/config_test_001.sh +++ b/ctdb/tests/UNIT/cunit/config_test_001.sh @@ -48,6 +48,7 @@ ok <