1

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.

1 Answer 1

1

Two options come to my mind:

  1. 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 recovering

    • if the result is f, PostgreSQL is done with recovery.

  2. set hot_standby = off in postgresql.conf

    Then PostgreSQL won't allow connections in recovery mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.