From 9bdf4baff2a2882d0da2c8837f0ebe93e3a90b61 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Mon, 7 Feb 2022 12:06:45 +0900 Subject: [PATCH] Fixed sample failover script. This script did not consider the case when the old primary node id is "-1". --- src/sample/scripts/failover.sh.sample | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sample/scripts/failover.sh.sample b/src/sample/scripts/failover.sh.sample index b9fac7dc5..91b541179 100755 --- a/src/sample/scripts/failover.sh.sample +++ b/src/sample/scripts/failover.sh.sample @@ -52,8 +52,14 @@ if [ $? -ne 0 ]; then exit 1 fi +## Check if all node is down +if [ $NEW_MAIN_NODE_ID = "-1" ]; then + echo failover.sh: end: no new main node is available. Skipping failover. + exit 0 +fi + ## If Standby node is down, skip failover. -if [ $FAILED_NODE_ID -ne $OLD_PRIMARY_NODE_ID ]; then +if [ $OLD_PRIMARY_NODE_ID != "-1" -a $FAILED_NODE_ID != $OLD_PRIMARY_NODE_ID ]; then # If Standby node is down, drop replication slot. ${PGHOME}/bin/psql -h ${OLD_PRIMARY_NODE_HOST} -p ${OLD_PRIMARY_NODE_PORT} \ -- 2.39.5