ctdb-recoverd: Always cancel election in progress
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Jan 2022 07:09:47 +0000 (18:09 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 14 Feb 2022 01:47:31 +0000 (01:47 +0000)
Election-in-progress is set by unknown leader broadcast, so needs to
be cleared in all cases when election completes.

This was seen in a case where the leader node stalled, so didn't send
leader broadcasts for some time.  The node continued to hold the
cluster lock, so another node could not become leader.  However, after
the node returned to normal it still did not send leader broadcasts
because election-in-progress was never cleared.

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

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c

index cc239959c56826340e9cce3c5548c848d2c9d875..7a13339bf37e95a27b28fa1ea2dcf82c253e46ae 100644 (file)
@@ -1836,7 +1836,7 @@ static void cluster_lock_election(struct ctdb_recoverd *rec)
                if (cluster_lock_held(rec)) {
                        cluster_lock_release(rec);
                }
-               return;
+               goto done;
        }
 
        /*
@@ -1844,7 +1844,7 @@ static void cluster_lock_election(struct ctdb_recoverd *rec)
         * attempt to retake it.  This provides stability.
         */
        if (cluster_lock_held(rec)) {
-               return;
+               goto done;
        }
 
        rec->leader = CTDB_UNKNOWN_PNN;
@@ -1856,6 +1856,7 @@ static void cluster_lock_election(struct ctdb_recoverd *rec)
                D_WARNING("Took cluster lock, leader=%"PRIu32"\n", rec->leader);
        }
 
+done:
        rec->election_in_progress = false;
 }