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