diff options
author | Fujii Masao <fujii@postgresql.org> | 2020-03-24 12:46:48 +0900 |
---|---|---|
committer | Fujii Masao <fujii@postgresql.org> | 2020-03-24 12:46:48 +0900 |
commit | 496ee647ecd2917369ffcf1eaa0b2cdca07c8730 (patch) | |
tree | 8b2b8aac0573b977442ad471b69702da8d203afc /doc/src | |
parent | e09ad07b21a244c3cbcdbe3048e9ab0834ac6d41 (diff) | |
download | postgresql-496ee647ecd2917369ffcf1eaa0b2cdca07c8730.tar.gz postgresql-496ee647ecd2917369ffcf1eaa0b2cdca07c8730.zip |
Prefer standby promotion over recovery pause.
Previously if a promotion was triggered while recovery was paused,
the paused state continued. Also recovery could be paused by executing
pg_wal_replay_pause() even while a promotion was ongoing. That is,
recovery pause had higher priority over a standby promotion.
But this behavior was not desirable because most users basically wanted
the recovery to complete as soon as possible and the server to become
the master when they requested a promotion.
This commit changes recovery so that it prefers a promotion over
recovery pause. That is, if a promotion is triggered while recovery
is paused, the paused state ends and a promotion continues. Also
this commit makes recovery pause functions like pg_wal_replay_pause()
throw an error if they are executed while a promotion is ongoing.
Internally, this commit adds new internal function PromoteIsTriggered()
that returns true if a promotion is triggered. Since the name of
this function and the existing function IsPromoteTriggered() are
confusingly similar, the commit changes the name of IsPromoteTriggered()
to IsPromoteSignaled, as more appropriate name.
Author: Fujii Masao
Reviewed-by: Atsushi Torikoshi, Sergei Kornilov
Discussion: https://postgr.es/m/00c194b2-dbbb-2e8a-5b39-13f14048ef0a@oss.nttdata.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 3 | ||||
-rw-r--r-- | doc/src/sgml/func.sgml | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 70854ae2986..355b408b0a6 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3590,6 +3590,9 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows This setting has no effect if no recovery target is set. If <xref linkend="guc-hot-standby"/> is not enabled, a setting of <literal>pause</literal> will act the same as <literal>shutdown</literal>. + If the recovery target is reached while a promotion is ongoing, + a setting of <literal>pause</literal> will act the same as + <literal>promote</literal>. </para> <para> In any case, if a recovery target is configured but the archive diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 0057a177570..7a0bb0c70a1 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -20178,6 +20178,13 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </para> <para> + <function>pg_wal_replay_pause</function> and + <function>pg_wal_replay_resume</function> cannot be executed while + a promotion is ongoing. If a promotion is triggered while recovery + is paused, the paused state ends and a promotion continues. + </para> + + <para> If streaming replication is disabled, the paused state may continue indefinitely without problem. While streaming replication is in progress WAL records will continue to be received, which will |