pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: jlucasdba@gmail.com
Subject: BUG #15989: Cluster unable to open as hot standby after SIGKILL during exclusive backup
Date: Mon, 02 Sep 2019 13:53:47 +0000
Message-ID: <15989-bf9dee713231e7b0@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15989
Logged by:          James Lucas
Email address:      jlucasdba@gmail.com
PostgreSQL version: 11.5
Operating system:   Centos 7
Description:        

After being sent SIGKILL while exclusive backup is in effect, cluster
becomes unable to open as a hot standby.  Reproducible on (at least) 11.5
and 9.6.15.

Steps to reproduce on a fresh database cluster:

* Initialize new cluster.
initdb -D data

* Start cluster.
pg_ctl -D data start

* Verify hot_standby is enabled (Should return "on" on 11.5.  On 9.6.15,
need to enable it.)
psql -c 'show hot_standby'

* Verify wal_level is set to replica or logical (Okay on 11.5.  On 9.6.15
need to set and restart.)
psql -c 'show wal_level'

* Stop cluster.
pg_ctl -D data stop

* Add recovery.conf
echo 'standby_mode = true' >> data/recovery.conf

* Start as hot standby
pg_ctl -D data start

* Validate cluster is running as hot standby (should return true)
psql -c 'select pg_is_in_recovery()'

* Stop cluster
pg_ctl -D data stop

* Remove recovery.conf
rm data/recovery.conf

* Start cluster normally
pg_ctl -D data start

* Enable exclusive backup
psql -c "select pg_start_backup('')"

* Find pid of main postgres process
ps -ef | grep 'postgres -D'

* Send SIGKILL to found pid
kill -s KILL <pid>

* Add recovery.conf
echo 'standby_mode = true' >> data/recovery.conf

* Attempt to start cluster
pg_ctl -D data start

At this point, the cluster fails to open.  On 11.5 pg_ctl hangs waiting for
the database to open, and eventually times out.  On 9.6.15, pg_ctl runs
normally, but tailing the database log shows that it never opens.  It loops
at "starting up."

I've found that if you stop the instance and remove the recovery.conf, the
database actually will open normally.  But even after that, if you go back
and try to open as a hot standby it will fail to open again.  I have so far
not been able to find a way to let this cluster open as a hot standby again.
 Affected instances had to be restored from backup.

This is particularly a problem when running postgres in Docker, as Docker
will send SIGKILL if database shutdown takes more than a few seconds.

Please let me know if any questions.

Thanks,
James Lucas



view thread (2+ messages)  latest in thread

Message-ID: <15989-bf9dee713231e7b0@postgresql.org>
Permalink:  ../15989-bf9dee713231e7b0@postgresql.org/
Also on:    postgresql.org/message-id/15989-bf9dee713231e7b0@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, jlucasdba@gmail.com
  Subject: Re: BUG #15989: Cluster unable to open as hot standby after SIGKILL during exclusive backup
  In-Reply-To: <15989-bf9dee713231e7b0@postgresql.org>
  References: <15989-bf9dee713231e7b0@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox