Prefer standby promotion over recovery pause

Enterprise / PostgreSQL - Fujii Masao [postgresql.org] - 24 March 2020 03:46 EDT

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

496ee647ec Prefer standby promotion over recovery pause.
doc/src/sgml/config.sgml | 3 ++
doc/src/sgml/func.sgml | 7 ++++
src/backend/access/transam/xlog.c | 67 ++++++++++++++++++++++++++++++----
src/backend/access/transam/xlogfuncs.c | 14 +++++++
src/backend/postmaster/startup.c | 12 +++---
src/include/access/xlog.h | 1 +
src/include/postmaster/startup.h | 4 +-
7 files changed, 93 insertions(+), 15 deletions(-)

Upstream: git.postgresql.org


  • Share