]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Add configuration option shutdown extra timeout
authorMartin Schwenke <mschwenke@ddn.com>
Sun, 18 May 2025 23:06:38 +0000 (09:06 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 29 May 2025 09:56:31 +0000 (09:56 +0000)
See documentation change for details.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/conf/ctdb_config.c
ctdb/conf/ctdb_config.h
ctdb/conf/failover_conf.c
ctdb/conf/failover_conf.h
ctdb/doc/ctdb.conf.5.xml
ctdb/server/ctdb_daemon.c
ctdb/tests/UNIT/cunit/config_test_001.sh

index ba478550f6584f2776d8fdfe939bcbb437b07548..d9f6f3a5457aa581a0b7ea6384cfd05395346367 100644 (file)
@@ -110,6 +110,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,
index ee04a174d134df27dd428adb3136ad51590bbca3..01195a4c9f5da4ecd930ce35debbe307c1d15704 100644 (file)
@@ -44,6 +44,7 @@ struct ctdb_config {
 
        /* Failover */
        bool failover_disabled;
+       int shutdown_extra_timeout;
        int shutdown_failover_timeout;
 
        /* Legacy */
index 01b0b617827a024df174f57238be823fb0814c4f..424021b7a22656b0a418ce179a5350494328e1fe 100644 (file)
@@ -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,
index 34ab9c193b336e5759444930a9daba3e81334c21..08f5fb8939c32c6da4495cbf694c9fb2a93eedec 100644 (file)
@@ -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"
 
 
index 8666d92f8306f6dd985789561734578d4350d6e8..048e02196bb052ac131651da0f1462f292111e58 100644 (file)
        </listitem>
       </varlistentry>
 
+      <varlistentry>
+       <term>shutdown extra timeout = <parameter>TIMEOUT</parameter></term>
+       <listitem>
+         <para>
+           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.
+         </para>
+         <para>
+           This timeout only occurs if both of the following
+           conditions are true:
+         </para>
+         <itemizedlist>
+           <listitem>
+             <para>
+               shutdown failover timeout (below) is not 0
+             </para>
+           </listitem>
+           <listitem>
+             <para>
+               Failover during shutdown completes and does not time out
+             </para>
+           </listitem>
+         </itemizedlist>
+         <para>
+           Default: <literal>0</literal>
+         </para>
+       </listitem>
+      </varlistentry>
+
       <varlistentry>
        <term>shutdown failover timeout = <parameter>TIMEOUT</parameter></term>
        <listitem>
            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.
          </para>
          <para>
            Set this to 0 to disable explicit failover on shutdown.
index 650dc454574ac85d2793ffeb2f457ab1da8cbff3..9d422a2202ee0801b2dfdbab4ac4ed3c92f351f1 100644 (file)
@@ -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)
index fac4e15612aa169f974ceeb7281d1b3d94739fb0..b4d73a993aa9b569a5a0fba2a263462f810d6f71 100755 (executable)
@@ -49,6 +49,7 @@ ok <<EOF
        # debug script = 
 [failover]
        # disabled = false
+       # shutdown extra timeout = 0
        # shutdown failover timeout = 10
 [legacy]
        # realtime scheduling = true