Blame SOURCES/bz1640587-pgsql-ignore-masters-re-promote.patch

030326
From 355cd29f2dee828bfe0a4ab64f425827aba7dd3b Mon Sep 17 00:00:00 2001
030326
From: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
030326
Date: Wed, 17 Oct 2018 09:54:37 +0900
030326
Subject: [PATCH] Mid: pgsql: Fix to ignore Master's re-promote.
030326
030326
---
030326
 heartbeat/pgsql | 13 +++++++++++++
030326
 1 file changed, 13 insertions(+)
030326
030326
diff --git a/heartbeat/pgsql b/heartbeat/pgsql
030326
index 380866da1..38f6ceeb7 100755
030326
--- a/heartbeat/pgsql
030326
+++ b/heartbeat/pgsql
030326
@@ -680,6 +680,7 @@ pgsql_start() {
030326
 
030326
 #pgsql_promote: Promote PostgreSQL
030326
 pgsql_promote() {
030326
+    local output
030326
     local target
030326
     local rc
030326
 
030326
@@ -687,6 +688,18 @@ pgsql_promote() {
030326
         ocf_exit_reason "Not in a replication mode."
030326
         return $OCF_ERR_CONFIGURED
030326
     fi
030326
+
030326
+    output=`exec_sql "${CHECK_MS_SQL}"`
030326
+    if [ $? -ne 0 ]; then
030326
+        report_psql_error $rc $loglevel "Can't get PostgreSQL recovery status on promote."
030326
+        return $OCF_ERR_GENERIC
030326
+    fi
030326
+
030326
+    if [ "$output" = "f" ]; then
030326
+        ocf_log info "PostgreSQL is alredy Master. Don't execute promote."
030326
+        return $OCF_SUCCESS
030326
+    fi
030326
+
030326
     rm -f ${XLOG_NOTE_FILE}.*
030326
 
030326
     for target in $NODE_LIST; do