[pgpool-general: 4134] Re: Testing pgpool + failover on random servers restarts

Ioana Danes ioanadanes at gmail.com
Thu Oct 22 10:27:04 JST 2015



Sent from my BlackBerry 10 smartphone on the TELUS network.
  Original Message  
From: Tatsuo Ishii
Sent: Wednesday, October 21, 2015 8:18 PM
To: ioanadanes at gmail.com
Cc: pgpool-general at pgpool.net
Subject: Re: [pgpool-general: 4119] Testing pgpool + failover on random servers restarts

> Hello,
> 
> Sorry for late reply on this issue, I've been busy with other tasks.
> 
> On Fri, Oct 16, 2015 at 7:05 PM, Tatsuo Ishii <ishii at postgresql.org> wrote:
> 
>>
>> > Is there a way I
>> > could overcome this issue? I thought I could update the pgpool status
>> file
>> > in /var/log/pgpool in my scripts once a failover occurs. Would that be
>> the
>> > way to go or there are better ways to fix this?
>>
>> The situation above heavily relies on how you wrote pgpool_failover.sh
>> and pgpool_failback.sh. Also you'd better present how you start
>> pgpool. The point here is, you use -D or not.
>>
>>
> I start pgpool using the /etc/init.d/pgpool-II script:
> 
> PGPOOL2_BIN=/usr/sbin/pgpool
> test -x $PGPOOL2_BIN || { echo "$PGPOOL2_BIN not installed";
> if [ "$1" = "stop" ]; then exit 0;
> else exit 5; fi; }
> 
> # Check for existence of needed config file and read it
> PGPOOL2_CONFIG=/etc/sysconfig/pgpool-II
> test -r $PGPOOL2_CONFIG || { echo "$PGPOOL2_CONFIG not existing";
> if [ "$1" = "stop" ]; then exit 0;
> else exit 6; fi; }
> 
> # Read config
> . $PGPOOL2_CONFIG
> PGPOOL2_CONFFILE="/etc/pgpool-II/pgpool.conf"
> PGPOOL2_PID="/var/run/pgpool/pgpool.pid"
> 
> ...
> 
> start)
> echo -n "Starting pgpool "
> ## Start daemon with startproc(8). If this fails
> ## the return value is set appropriately by startproc.
> /sbin/startproc -u pgpool -g pgpool $PGPOOL2_BIN
> 
> # Remember status and be verbose
> rc_status -v
> sleep 1

Please show us "stop)" part as well.
‎
> and this is my failover script:
> 
> #!/bin/sh
> 
> crt_date=`date`
> echo "$crt_date : old master id=$1 new master id=$2 new master host=$3" >>
> ${log_file}
> 
> old_master_id=$1
> new_master_id=$2
> new_master_host=$3
> 
> if [ ${old_master_id} -ne ${new_master_id} ]
> then
> ssh root@${new_master_host}
> "/cbnDBscripts/DBCluster/dbcluster_promote_as_primary.sh" >
> /cbnDBscripts/log/pgpool_failover_${new_master_host}.log
> else
> ssh root@${new_master_host}
> "/cbnDBscripts/DBCluster/dbcluster_standby_failed.sh" >
> /cbnDBscripts/log/pgpool_failover_slave_${new_master_host}.log
> fi

Can you show me dbcluster_promote_as_primary.sh and dbcluster_standby_failed.sh?

Also it seems failback.sh is missing.

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp

Hello, 

Sorry I think I did not explain my problem very well. The failover, failback scripts work well with pgpool. If I stop the postgres on primary, the standby is promoted as expected. If I stop postgres on  the stand by and re attach it the failback script works as expected. Also if I stop pgpool properly from the script it saves the current status of the cluster in the /var/log/pgpool/pgpool_status file and when I start it back it restores the right status. 
The problem is that the status file is not updated when the failover and the failback is happening so if the pgpool does not stop properly from the script and I just unplug the server or I kill pgpool the current status is lost and I might end up in a split brain at the database level. I can update the status file in my scripts when a failover or failback occur to preserve the status, but I was currious if that is the right way to do it or I missed something.
 Thanks a lot,
Ioana


More information about the pgpool-general mailing list