From c8373d4aea13b881bfbd17ff060516ca35055b49 Mon Sep 17 00:00:00 2001 From: Vladimir Kuklin Date: Fri, 28 Apr 2017 13:43:49 +0300 Subject: [PATCH] Fix race condition for primary component bootstrap Create node is_pc flag before starting to check if there is more than one of those flags. Thus, we avoid race condition when there is 0 is_pc flags and galera starts with --wsrep-new-cluster on 2 nodes. We set it before the check and, as setting them is synchronous through Pacemaker CIB, in that case when >1 nodes attempt to bootstrap with --wsrep-new-cluster, only one node will see <= 1 is_pc flags. Others will see more than one and fail and reattempt to start. At that point one of the nodes will already be bootstrapped, thus reelection will not be triggered and the section of bootstrap will be skipped Change-Id: I82a71132eef7877ac7ab1ed04263044b3b1e8d9b Closes-bug: #1617400 Signed-off-by: Sergii Golovatiuk --- files/fuel-ha-utils/ocf/mysql-wss | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/files/fuel-ha-utils/ocf/mysql-wss b/files/fuel-ha-utils/ocf/mysql-wss index be060798ee..77067acd18 100755 --- a/files/fuel-ha-utils/ocf/mysql-wss +++ b/files/fuel-ha-utils/ocf/mysql-wss @@ -503,6 +503,7 @@ check_if_galera_pc() { fi if [ ${pcnum} -gt 1 ]; then ocf_log err "${LH} But I'm running a new cluster, PID:${pid}, this is a split-brain!" + clear_node_pc exit $OCF_ERR_GENERIC fi done @@ -676,8 +677,6 @@ mysql_start() { local rc local dir local mysql_extra_params - local set_pc=0 - if mysql_status info 1; then ocf_log info "${LH} MySQL already running" @@ -729,12 +728,13 @@ mysql_start() { rc=$? if [ $rc -eq 0 ]; then - mysql_extra_params="$mysql_extra_params --wsrep-new-cluster" - set_pc=1 + mysql_extra_params="$mysql_extra_params --wsrep-new-cluster" + update_node_pc + else + clear_node_pc fi fi - clear_node_pc ocf_log info "${LH} Starting MySQL" ${OCF_RESKEY_binary} \ --pid-file=$OCF_RESKEY_pid \ @@ -746,6 +746,7 @@ mysql_start() { if [ $rc -ne 0 ]; then ocf_log err "${LH} MySQL start command failed: $rc" + clear_node_pc return $rc fi @@ -763,8 +764,6 @@ mysql_start() { done ocf_log info "${LH} MySQL started" - [ ${set_pc} -eq 1 ] && update_node_pc - [ $rc -ne $OCF_SUCCESS ] && update_node_gtid return $OCF_SUCCESS }