Fix pgpool_setup in failover scrip creation.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 6 Feb 2022 07:23:46 +0000 (16:23 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 6 Feb 2022 08:24:50 +0000 (17:24 +0900)
When pgpool_set creates failover.sh, it did not consider the case when
no primary server existed.

src/test/pgpool_setup.in

index b00400b3a8dc91c891cbb975888365c1c9d801c3..21efe265a6d697a5228114fd4838b4da708b13c5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (c) 2013-2020 PgPool Global Development Group
+# Copyright (c) 2013-2022 PgPool Global Development Group
 #
 # Permission to use, copy, modify, and distribute this software and
 # its documentation for any purpose and without fee is hereby
@@ -188,8 +188,8 @@ if [ $new_master_id = "-1" ];then
     exit 0
 fi
 
-if [ a"$failed_node_id" = a"$old_primary_node_id" ];then       # master failed
-!      new_primary_db_cluster=${mydir}/data"$new_master_id"
+if [ a"$failed_node_id" = a"$old_primary_node_id" -o a"$old_primary_node_id" = a"-1" ];then    # master node failed
+       new_primary_db_cluster=${mydir}/data"$new_main_id"
        echo $pg_ctl -D $new_primary_db_cluster promote >>$log  # let standby take over
        $pg_ctl -D $new_primary_db_cluster promote >>$log       # let standby take over
 fi