From ac213f158ff851422d78ae8f56b022e8e30751bc Mon Sep 17 00:00:00 2001
From: Damien Ciabrini <damien.ciabrini@gmail.com>
Date: Mon, 26 Oct 2020 14:54:05 +0100
Subject: [PATCH] galera: set bootstrap attribute before promote
When the master detection takes place, the node chosen for
becoming the master is given two attributes in the CIB:
a master score and a bootstrap flag. The master score makes
pacemaker schedule a promote operation, and the bootstrap flag
drives how the galera server is started.
The order in which we set the attributes is racy; it may happen
that a promote operation is started before the current master
detection function has set the bootstrap flag, in which case
the promotion will fail.
Reverse the order in which we set the attributes on a bootstrap
node to close the race.
---
heartbeat/galera | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/heartbeat/galera b/heartbeat/galera
index d2f4faa86..b4d7e187d 100755
--- a/heartbeat/galera
+++ b/heartbeat/galera
@@ -587,8 +587,8 @@ detect_first_master()
fi
ocf_log info "Promoting $best_node to be our bootstrap node"
- set_master_score $best_node
set_bootstrap_node $best_node
+ set_master_score $best_node
}
detect_safe_to_bootstrap()