]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-recoverd: Do not allow nested elections
authorMartin Schwenke <mschwenke@ddn.com>
Tue, 12 May 2026 07:40:05 +0000 (17:40 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 9 Jul 2026 15:24:42 +0000 (15:24 +0000)
This appears to show nested elections:

  2026-05-12T12:15:56.130174+05:30 nsds1 ctdb-recoverd[826]: Leader broadcast timeout
  2026-05-12T12:15:56.130206+05:30 nsds1 ctdb-recoverd[826]: Start election
  2026-05-12T12:15:56.130329+05:30 nsds1 ctdb-recoverd[826]: Attempting to take cluster lock (!/usr/libexec/ctdb/ctdb_mutex_fcntl_helper /mnt/lustre/mac167/nsds_conf/.nsds_config/cluster_lock 5 20)
  2026-05-12T12:16:01.131882+05:30 nsds1 ctdb-recoverd[826]: Leader broadcast timeout
  2026-05-12T12:16:01.131918+05:30 nsds1 ctdb-recoverd[826]: Start election

There is no sign that the first election ended.  Starting another one
causes bad state interactions.  Apart from causing confusion for
multiple pieces of state (e.g. rec->election_in_progress), a nested
call to _cluster_lock_lock() will leak rec->cluster_lock_handle
because it will overwrite it with the new in-progress handle.

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

Reported-by: Agam S <sagam@ddn.com>
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Jul  9 15:24:42 UTC 2026 on atb-devel-224

ctdb/server/ctdb_recoverd.c

index 40a6aadd40fcb16dddf993eabe4b6273e262c081..aacf886dae89de240053af4a45aef8436a52cdfd 100644 (file)
@@ -1918,6 +1918,11 @@ static void force_election(struct ctdb_recoverd *rec)
 
        D_ERR("Start election\n");
 
+       /* Do not allow nested elections */
+       if (rec->election_in_progress) {
+               return;
+       }
+
        /* set all nodes to recovery mode to stop all internode traffic */
        ret = set_recovery_mode(ctdb, rec, rec->nodemap, CTDB_RECOVERY_ACTIVE);
        if (ret != 0) {