Waiting for PostgreSQL 12 – Integrate recovery.conf into postgresql.conf

On 25th of November 2018, Peter Eisentraut committed patch:

Integrate recovery.conf into postgresql.conf
 
recovery.conf settings are now set in postgresql.conf (or other GUC
sources).  Currently, all the affected settings are PGC_POSTMASTER;
this could be refined in the future case by case.
 
Recovery is now initiated by a file recovery.signal.  Standby mode is
initiated by a file standby.signal.  The standby_mode setting is
gone.  If a recovery.conf file is found, an error is issued.
 
The trigger_file setting has been renamed to promote_trigger_file as
part of the move.
 
The documentation chapter "Recovery Configuration" has been integrated
into "Server Configuration".
 
pg_basebackup -R now appends settings to postgresql.auto.conf and
creates a standby.signal file.
 
Author: Fujii Masao
Author: Simon Riggs
Author: Abhijit Menon-Sen
Author: Sergei Kornilov
Discussion: https://www.postgresql.org/message-id/flat/@web3g.yandex.ru/

This is big change, one that can potentially cause problems when upgrading from earlier versions to PostgreSQL 12.

First, let's list all things that could be configured in recovery.conf in Pg11:

Quite a lot of things.

Most of them are named the same, but are configured in postgresql.conf. There are changes, though:

  • instead of trigger_file there is promote_trigger_file
  • standby_mode is completely gone

So, to test it, I figured I'll make myself a copy of my test PGDATA:

=$ pg_basebackup -D data-2 -R --verbose
pg_basebackup: initiating base backup, waiting for checkpoint to complete
pg_basebackup: checkpoint completed
pg_basebackup: write-ahead log start point: 0/C000028 on timeline 1
pg_basebackup: starting background WAL receiver
pg_basebackup: created temporary replication slot "pg_basebackup_23907"
pg_basebackup: write-ahead log end point: 0/C0000F8
pg_basebackup: waiting for background process to finish streaming ...
pg_basebackup: syncing data to disk ...
pg_basebackup: base backup completed

Afterwards, I had two files that are in master, but are absent in data-2: postmaster.opts and postmaster.pid – but these are created by starting PostgreSQL, so it's good that they are gone.

I also had:

  • new file, with size 0, named standby.signal
  • file postgresql.auto.conf that I had before, with just some comments, but now it contained also this one line:
    primary_conninfo = 'user=pgdba passfile=''/home/pgdba/.pgpass'' port=5120 sslmode=prefer sslcompression=0 target_session_attrs=any'

Given that both instances are on the same server, I did:

=$ echo port=9999 >> data-2/postgresql.auto.conf
=$ pg_ctl -D data-2 start

And it worked.

If I'd remove standby.signal file before starting, then this new Pg will start as master on its own.

Currently it looks that all params need restart to be reloaded, but it doesn't seem like all that big of a problem.

All in all – it's nice that we will have single configuration source now, thanks to all involved.