Blame SOURCES/bz1795535-pgsql-1-add-postgresql-12-support.patch

030326
From a43075be72683e1d4ddab700ec16d667164d359c Mon Sep 17 00:00:00 2001
030326
From: Kazutomo Nakahira <kazutomo_nakahira@newson.co.jp>
030326
Date: Mon, 25 Nov 2019 17:40:33 +0900
030326
Subject: [PATCH 1/2] High: pgsql: Support for PostgreSQL 12
030326
030326
---
030326
 heartbeat/pgsql | 32 +++++++++++++++++++++++++++++++-
030326
 1 file changed, 31 insertions(+), 1 deletion(-)
030326
030326
diff --git a/heartbeat/pgsql b/heartbeat/pgsql
030326
index b1c070ead..5bc76cc4c 100755
030326
--- a/heartbeat/pgsql
030326
+++ b/heartbeat/pgsql
030326
@@ -1612,12 +1612,24 @@ make_recovery_conf() {
030326
     fi
030326
 
030326
 cat > $RECOVERY_CONF <
030326
-standby_mode = 'on'
030326
 primary_conninfo = 'host=${OCF_RESKEY_master_ip} port=${OCF_RESKEY_pgport} user=${OCF_RESKEY_repuser} application_name=${NODENAME} ${OCF_RESKEY_primary_conninfo_opt}'
030326
 restore_command = '${OCF_RESKEY_restore_command}'
030326
 recovery_target_timeline = 'latest'
030326
 END
030326
 
030326
+    if "${USE_STANDBY_SIGNAL}"; then
030326
+        # create a standby.signal to start standby server.
030326
+        runasowner "touch ${OCF_RESKEY_pgdata}/standby.signal"
030326
+        if [ $? -ne 0 ]; then
030326
+            ocf_exit_reason "Can't create ${OCF_RESKEY_pgdata}/standby.signal."
030326
+            return 1
030326
+        fi
030326
+    else
030326
+cat >> $RECOVERY_CONF <
030326
+standby_mode = 'on'
030326
+END
030326
+    fi
030326
+
030326
     user_recovery_conf >> $RECOVERY_CONF
030326
     ocf_log debug "Created recovery.conf. host=${OCF_RESKEY_master_ip}, user=${OCF_RESKEY_repuser}"
030326
     return 0
030326
@@ -1835,6 +1847,7 @@ pgsql_validate_all() {
030326
     local version
030326
     local check_config_rc
030326
     local rep_mode_string
030326
+    local recovery_conf_string
030326
     local socket_directories
030326
     local rc
030326
 
030326
@@ -1898,6 +1911,22 @@ pgsql_validate_all() {
030326
             ocf_exit_reason "Replication mode needs PostgreSQL 9.1 or higher."
030326
             return $OCF_ERR_INSTALLED
030326
         fi
030326
+        ocf_version_cmp "$version" "12"
030326
+        rc=$?
030326
+        if [ $rc -eq 1 ]||[ $rc -eq 2 ]; then
030326
+            # change the standby method for PosrgreSQL 12 or later.
030326
+            USE_STANDBY_SIGNAL=true
030326
+            # change the path to recovery.conf because it cause PostgreSQL start error.
030326
+            RECOVERY_CONF=${OCF_RESKEY_tmpdir}/recovery.conf
030326
+            if [ $check_config_rc -eq 0 ]; then
030326
+                # adding recovery parameters to postgresql.conf.
030326
+                recovery_conf_string="include '$RECOVERY_CONF' # added by pgsql RA"
030326
+                if ! grep -q "^[[:space:]]*$recovery_conf_string" $OCF_RESKEY_config; then
030326
+                    ocf_log info "adding include directive $recovery_conf_string into $OCF_RESKEY_config"
030326
+                    echo "$recovery_conf_string" >> $OCF_RESKEY_config
030326
+                fi
030326
+            fi
030326
+        fi
030326
         if [ ! -n "$OCF_RESKEY_master_ip" ]; then
030326
             ocf_exit_reason "master_ip can't be empty."
030326
             return $OCF_ERR_CONFIGURED
030326
@@ -2107,6 +2136,7 @@ RESOURCE_NAME=`echo $OCF_RESOURCE_INSTANCE | cut -d ":" -f 1`
030326
 PGSQL_WAL_RECEIVER_STATUS_ATTR="${RESOURCE_NAME}-receiver-status"
030326
 RECOVERY_CONF=${OCF_RESKEY_pgdata}/recovery.conf
030326
 NODENAME=$(ocf_local_nodename | tr '[A-Z]' '[a-z]')
030326
+USE_STANDBY_SIGNAL=false
030326
 
030326
 case "$1" in
030326
     methods)    pgsql_methods
030326
030326
From 5ab3339e8cb236583d375f5577f5a4dc129d5b27 Mon Sep 17 00:00:00 2001
030326
From: munenari <munenari@gmail.com>
030326
Date: Thu, 16 Jan 2020 09:27:59 +0900
030326
Subject: [PATCH 2/2] Remove standby.signal when promote with restart
030326
030326
---
030326
 heartbeat/pgsql | 6 +++++-
030326
 1 file changed, 5 insertions(+), 1 deletion(-)
030326
030326
diff --git a/heartbeat/pgsql b/heartbeat/pgsql
030326
index 5bc76cc4c..d5baa7b35 100755
030326
--- a/heartbeat/pgsql
030326
+++ b/heartbeat/pgsql
030326
@@ -720,7 +720,11 @@ pgsql_promote() {
030326
         ocf_log info "Restarting PostgreSQL instead of promote."
030326
         #stop : this function returns $OCF_SUCCESS only.
030326
         pgsql_real_stop slave
030326
-        rm -f $RECOVERY_CONF
030326
+        if "${USE_STANDBY_SIGNAL}"; then
030326
+            rm -f ${OCF_RESKEY_pgdata}/standby.signal
030326
+        else
030326
+            rm -f $RECOVERY_CONF
030326
+        fi
030326
         pgsql_real_start
030326
         rc=$?
030326
         if [ $rc -ne $OCF_RUNNING_MASTER ]; then