Contents
pg_wal_replay_pause()
pg_wal_replay_pause()
is a system function for pausing WAL replay (recovery) on a standby.
pg_wal_replay_pause()
was added in PostgreSQL 9.1 as pg_xlog_replay_pause()
.
Usage
pg_wal_replay_pause() → void
pg_wal_replay_pause()
issues a request to PostgreSQL to pause replay; once successful, no further changes are applied. Execute pg_wal_replay_resume()
to resume WAL replay.
Note that although pg_wal_replay_pause()
returns immediately, there may be a delay before WAL replay is actually paused. The point at which reply was paused is noted in the PostgreSQL logfile with an entry like:
LOG: 00000: recovery has paused
From PostgreSQL 14 the function pg_get_wal_replay_pause_state()
is also available to determine the status of a replay pause request.
Change history
- PostgreSQL 10
- renamed to
pg_wal_replay_pause()
(commit 806091c9)
- renamed to
- PostgreSQL 9.1
- added as
pg_xlog_replay_pause()
(commit 8c6e3adb)
- added as
Examples
Basic usage of pg_wal_replay_pause()
:
postgres=# SELECT pg_wal_replay_pause(); pg_wal_replay_pause --------------------- (1 row) postgres=# SELECT pg_get_wal_replay_pause_state(); pg_get_wal_replay_pause_state ------------------------------- paused (1 row) postgres=# SELECT pg_wal_replay_resume(); pg_wal_replay_resume ---------------------- (1 row)
This generates entries like the following in the PostgreSQL logfile:
[2021-04-06 15:14:24 UTC] psql postgres postgres LOG: 00000: statement: SELECT pg_wal_replay_pause(); [2021-04-06 15:14:24 UTC] LOG: 00000: recovery has paused [2021-04-06 15:14:24 UTC] HINT: Execute pg_wal_replay_resume() to continue. [2021-04-06 15:14:34 UTC] psql postgres postgres LOG: 00000: statement: SELECT pg_get_wal_replay_pause_state(); [2021-04-06 15:14:58 UTC] psql postgres postgres LOG: 00000: statement: SELECT pg_wal_replay_resume();
References
- PostgreSQL documentation: Recovery Control Functions