Why does PostgreSQL accept connections during recovery?
I wanted to use ps_isready
to determine if my database is done recovering from a backup and ready to accept connections. But it says the database is ready long before it is actually done recovering.
I now check if the recovery.signal
file exists, but I wonder if there is a "better" way to determine if it is done recovering.
Add a comment
|
1 Answer
Two options come to my mind:
connect and check if PostgreSQL is no longer in recovery mode:
psql -Atq -c 'SELECT pg_is_in_recovery()'
if the connection fails, PostgreSQL isn't up
if the result is
t
, PostgreSQL is recoveringif the result is
f
, PostgreSQL is done with recovery.
set
hot_standby = off
inpostgresql.conf
Then PostgreSQL won't allow connections in recovery mode.