|
|
7a920e |
From 422ef6a2018ebf9d6765e1f2965778f42c6a9d9c Mon Sep 17 00:00:00 2001
|
|
|
7a920e |
From: Damien Ciabrini <dciabrin@redhat.com>
|
|
|
7a920e |
Date: Tue, 15 Mar 2016 18:45:13 +0100
|
|
|
7a920e |
Subject: [PATCH] galera: don't bootstrap from a node with no grastate.dat when
|
|
|
7a920e |
possible
|
|
|
7a920e |
|
|
|
7a920e |
---
|
|
|
7a920e |
heartbeat/README.galera | 9 ++++-----
|
|
|
7a920e |
heartbeat/galera | 36 ++++++++++++++++++++++--------------
|
|
|
7a920e |
2 files changed, 26 insertions(+), 19 deletions(-)
|
|
|
7a920e |
|
|
|
7a920e |
diff --git a/heartbeat/galera b/heartbeat/galera
|
|
|
7a920e |
index 72add3c..e4495be 100755
|
|
|
7a920e |
--- a/heartbeat/galera
|
|
|
7a920e |
+++ b/heartbeat/galera
|
|
|
7a920e |
@@ -276,20 +276,20 @@ is_bootstrap()
|
|
|
7a920e |
|
|
|
7a920e |
}
|
|
|
7a920e |
|
|
|
7a920e |
-set_heuristic_recovered()
|
|
|
7a920e |
+set_no_grastate()
|
|
|
7a920e |
{
|
|
|
7a920e |
- ${HA_SBIN_DIR}/crm_attribute -N $NODENAME -l reboot --name "${INSTANCE_ATTR_NAME}-heuristic-recovered" -v "true"
|
|
|
7a920e |
+ ${HA_SBIN_DIR}/crm_attribute -N $NODENAME -l reboot --name "${INSTANCE_ATTR_NAME}-no-grastate" -v "true"
|
|
|
7a920e |
}
|
|
|
7a920e |
|
|
|
7a920e |
-clear_heuristic_recovered()
|
|
|
7a920e |
+clear_no_grastate()
|
|
|
7a920e |
{
|
|
|
7a920e |
- ${HA_SBIN_DIR}/crm_attribute -N $NODENAME -l reboot --name "${INSTANCE_ATTR_NAME}-heuristic-recovered" -D
|
|
|
7a920e |
+ ${HA_SBIN_DIR}/crm_attribute -N $NODENAME -l reboot --name "${INSTANCE_ATTR_NAME}-no-grastate" -D
|
|
|
7a920e |
}
|
|
|
7a920e |
|
|
|
7a920e |
-is_heuristic_recovered()
|
|
|
7a920e |
+is_no_grastate()
|
|
|
7a920e |
{
|
|
|
7a920e |
local node=$1
|
|
|
7a920e |
- ${HA_SBIN_DIR}/crm_attribute -N $node -l reboot --name "${INSTANCE_ATTR_NAME}-heuristic-recovered" -Q 2>/dev/null
|
|
|
7a920e |
+ ${HA_SBIN_DIR}/crm_attribute -N $node -l reboot --name "${INSTANCE_ATTR_NAME}-no-grastate" -Q 2>/dev/null
|
|
|
7a920e |
}
|
|
|
7a920e |
|
|
|
7a920e |
clear_last_commit()
|
|
|
7a920e |
@@ -419,7 +419,7 @@ detect_first_master()
|
|
|
7a920e |
|
|
|
7a920e |
# avoid selecting a recovered node as bootstrap if possible
|
|
|
7a920e |
for node in $(echo "$OCF_RESKEY_wsrep_cluster_address" | sed 's/gcomm:\/\///g' | tr -d ' ' | tr -s ',' ' '); do
|
|
|
7a920e |
- if is_heuristic_recovered $node; then
|
|
|
7a920e |
+ if is_no_grastate $node; then
|
|
|
7a920e |
nodes_recovered="$nodes_recovered $node"
|
|
|
7a920e |
else
|
|
|
7a920e |
nodes="$nodes $node"
|
|
|
7a920e |
@@ -473,6 +473,12 @@ detect_last_commit()
|
|
|
7a920e |
local tmp=$(mktemp)
|
|
|
7a920e |
local tmperr=$(mktemp)
|
|
|
7a920e |
|
|
|
7a920e |
+ # if we pass here because grastate.dat doesn't exist,
|
|
|
7a920e |
+ # try not to bootstrap from this node if possible
|
|
|
7a920e |
+ if [ ! -f ${OCF_RESKEY_datadir}/grastate.dat ]; then
|
|
|
7a920e |
+ set_no_grastate
|
|
|
7a920e |
+ fi
|
|
|
7a920e |
+
|
|
|
7a920e |
ocf_log info "now attempting to detect last commit version using 'mysqld_safe --wsrep-recover'"
|
|
|
7a920e |
|
|
|
7a920e |
${OCF_RESKEY_binary} $recover_args --wsrep-recover > $tmp 2> $tmperr
|
|
|
7a920e |
@@ -496,8 +502,8 @@ detect_last_commit()
|
|
|
7a920e |
if [ ! -z "$last_commit" ]; then
|
|
|
7a920e |
ocf_log warn "State recovered. force SST at next restart for full resynchronization"
|
|
|
7a920e |
rm -f ${OCF_RESKEY_datadir}/grastate.dat
|
|
|
7a920e |
- # try not to use this node if bootstrap is needed
|
|
|
7a920e |
- set_heuristic_recovered
|
|
|
7a920e |
+ # try not to bootstrap from this node if possible
|
|
|
7a920e |
+ set_no_grastate
|
|
|
7a920e |
fi
|
|
|
7a920e |
fi
|
|
|
7a920e |
fi
|
|
|
7a920e |
@@ -582,17 +588,17 @@ galera_promote()
|
|
|
7a920e |
if ocf_is_true $bootstrap; then
|
|
|
7a920e |
promote_everyone
|
|
|
7a920e |
clear_bootstrap_node
|
|
|
7a920e |
- # clear attribute heuristic-recovered. if last shutdown was
|
|
|
7a920e |
+ # clear attribute no-grastate. if last shutdown was
|
|
|
7a920e |
# not clean, we cannot be extra-cautious by requesting a SST
|
|
|
7a920e |
# since this is the bootstrap node
|
|
|
7a920e |
- clear_heuristic_recovered
|
|
|
7a920e |
+ clear_no_grastate
|
|
|
7a920e |
ocf_log info "Bootstrap complete, promoting the rest of the galera instances."
|
|
|
7a920e |
else
|
|
|
7a920e |
# if this is not the bootstrap node, make sure this instance
|
|
|
7a920e |
# syncs with the rest of the cluster before promotion returns.
|
|
|
7a920e |
wait_for_sync
|
|
|
7a920e |
- # sync is done, clear info about last recovery
|
|
|
7a920e |
- clear_heuristic_recovered
|
|
|
7a920e |
+ # sync is done, clear info about last startup
|
|
|
7a920e |
+ clear_no_grastate
|
|
|
7a920e |
fi
|
|
|
7a920e |
|
|
|
7a920e |
ocf_log info "Galera started"
|
|
|
7a920e |
@@ -611,6 +617,7 @@ galera_demote()
|
|
|
7a920e |
# if this node was previously a bootstrap node, that is no longer the case.
|
|
|
7a920e |
clear_bootstrap_node
|
|
|
7a920e |
clear_last_commit
|
|
|
7a920e |
+ clear_no_grastate
|
|
|
7a920e |
|
|
|
7a920e |
# record last commit for next promotion
|
|
|
7a920e |
detect_last_commit
|
|
|
7a920e |
@@ -722,6 +729,7 @@ galera_stop()
|
|
|
7a920e |
clear_last_commit
|
|
|
7a920e |
clear_master_score
|
|
|
7a920e |
clear_bootstrap_node
|
|
|
7a920e |
+ clear_no_grastate
|
|
|
7a920e |
return $rc
|
|
|
7a920e |
}
|
|
|
7a920e |
|