Fix follow primary command creation in pgpool_setup.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 25 Jun 2021 10:58:53 +0000 (19:58 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 25 Jun 2021 10:58:53 +0000 (19:58 +0900)
If the target node of the follow primary script is primary and the
server version is before PostgreSQL 12, then the follow primary
command fails because there's no recovery.conf (12 or later is fine,
because "standby.signal" and "myrecovery.conf" are created).

To fix this, if server version is before 12, rename recovery.done to
recovery.conf.

Also this should fix 034.promote_node failure with PostgreSQL 11 or
before.

src/test/pgpool_setup.in

index 7a8c25d6f894cc4c4fe1e72f905daed5021cad43..c650cb20c74db3086bf5f4efa501fb1036d71d6a 100644 (file)
@@ -271,6 +271,10 @@ then
         sed -i "s/port=[0-9]*/port=$new_primary_port_number/" $db_cluster/myrecovery.conf
         sed -i "/restore_command/s/data[0-9]/`basename $new_primary_db_cluster`/" $db_cluster/myrecovery.conf
     else
+       # if recovery.conf is not found, rename recovery.done.
+       if [ ! -f $db_cluster/recovery.conf ];then
+          mv $db_cluster/recovery.done $db_cluster/recovery.conf
+       fi
         sed -i "s/port=[0-9]*/port=$new_primary_port_number/" $db_cluster/recovery.conf
         sed -i "/restore_command/s/data[0-9]/`basename $new_primary_db_cluster`/" $db_cluster/recovery.conf
     fi