Skip to content

Commit 624dc9e

Browse files
committed
Fetch up-to-date gcomm members list during a failover
The operator script that implements service endpoint failover contains internal logic to probe the up-to-date state of the gcomm cluster. This is done when the script starts, or when a command failed and is retried. The list of members was incorrectly extracted from a mysql table which is not guaranteed to be up-to-date when e.g. a node disappears from the cluster due to a network partition. Instead, we must rely on the mysql status, that always exposes the up-to-date gcomm state, in particular the members that are still connected to the primary partition. Jira: OSPRH-18408
1 parent 0a36c2e commit 624dc9e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

templates/galera/bin/mysql_wsrep_notify.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,22 @@ function mysql_get_status {
4242
}
4343

4444
function mysql_get_members {
45-
mysql -nN -uroot -p"${DB_ROOT_PASSWORD}" -e "select node_name from mysql.wsrep_cluster_members;"
46-
local rc=$?
47-
[ $rc = 0 ] || log_error "could not get cluster members from mysql' (rc=$rc)"
45+
# The up-to-date list of members in this partition are precisely the incoming gcomm
46+
# addresses, which can be extracted from mysql status.
47+
# system table mysql.wsrep_cluster_members also exposes that information, but it
48+
# contains stale information during a state transition (e.g. when a node just
49+
# disappeared).
50+
# For accuracy, we only rely on current mysql status, as the data exactly matches
51+
# the value of argument `--members` passed to this script.
52+
local addresses
53+
local rc
54+
addresses=$(mysql_get_status wsrep_incoming_addresses)
55+
rc=$?
56+
if [ $rc = 0 ]; then
57+
# galera-0.subdomain:3306,galera-1.subdomain:3306,galera-2.subdomain:3306
58+
echo -n "${addresses}" | tr ',' '\n' | cut -d. -f1
59+
fi
60+
return $rc
4861
}
4962

5063
# When optional script parameters are not provided, set up the environment

0 commit comments

Comments
 (0)