From 114b9396eca5be447b6b2d114500702fb25b1612 Mon Sep 17 00:00:00 2001 From: Gianluca Borello Date: Tue, 18 Sep 2018 09:12:01 -0700 Subject: [PATCH] Switch to the mysql_innodb_cluster_metadata table as a mechanism for checking the number of members in the cluster. This has the advantage that, once fully formed, it never shrinks even if a member goes offline, so that starting the router container in a scenario when one mysql replica is down doesn't fail. Such scenario can frequently occur when the router is deployed alongside with the client application. Signed-off-by: Gianluca Borello --- 8.0/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/8.0/run.sh b/8.0/run.sh index c23a5041..d9bf233b 100755 --- a/8.0/run.sh +++ b/8.0/run.sh @@ -38,7 +38,7 @@ if [ "$1" = 'mysqlrouter' ]; then done echo "Succesfully contacted mysql server at $MYSQL_HOST. Checking for cluster state." attempt_num=0 - until [ "$(mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -h "$MYSQL_HOST" -P "$MYSQL_PORT" -N performance_schema -e "select count(MEMBER_STATE) = $MYSQL_INNODB_NUM_MEMBERS from replication_group_members where MEMBER_STATE = 'ONLINE';" 2> /dev/null)" -eq 1 ]; do + until [ "$(mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -h "$MYSQL_HOST" -P "$MYSQL_PORT" -N mysql_innodb_cluster_metadata -e "select count(*) = $MYSQL_INNODB_NUM_MEMBERS FROM instances WHERE replicaset_id = (SELECT replicaset_id FROM instances WHERE mysql_server_uuid = @@server_uuid);" 2> /dev/null)" -eq 1 ]; do echo "Waiting for $MYSQL_INNODB_NUM_MEMBERS cluster instances to become available via $MYSQL_HOST ($attempt_num/$max_tries)" sleep $(( attempt_num++ )) if (( attempt_num == max_tries )); then