diff options
author | Andres Freund <andres@anarazel.de> | 2023-04-08 02:20:01 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2023-04-08 02:20:05 -0700 |
commit | 0fdab27ad68a059a1663fa5ce48d76333f1bd74c (patch) | |
tree | 3d29650901130428712f71cbb8b57cb19f738f1a /src/backend/access/transam/xlog.c | |
parent | e101dfac3a53c20bfbf1ca85d30a368c2954facf (diff) | |
download | postgresql-0fdab27ad68a059a1663fa5ce48d76333f1bd74c.tar.gz postgresql-0fdab27ad68a059a1663fa5ce48d76333f1bd74c.zip |
Allow logical decoding on standbys
Unsurprisingly, this requires wal_level = logical to be set on the primary and
standby. The infrastructure added in 26669757b6a ensures that slots are
invalidated if the primary's wal_level is lowered.
Creating a slot on a standby waits for a xl_running_xact record to be
processed. If the primary is idle (and thus not emitting xl_running_xact
records), that can take a while. To make that faster, this commit also
introduces the pg_log_standby_snapshot() function. By executing it on the
primary, completion of slot creation on the standby can be accelerated.
Note that logical decoding on a standby does not itself enforce that required
catalog rows are not removed. The user has to use physical replication slots +
hot_standby_feedback or other measures to prevent that. If catalog rows
required for a slot are removed, the slot is invalidated.
See 6af1793954e for an overall design of logical decoding on a standby.
Bumps catversion, for the addition of the pg_log_standby_snapshot() function.
Author: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com>
Author: Andres Freund <andres@anarazel.de> (in an older version)
Author: Amit Khandekar <amitdkhan.pg@gmail.com> (in an older version)
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: FabrÃŒzio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-By: Robert Haas <robertmhaas@gmail.com>
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 1b7c2f23a41..b540ee293b6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4470,6 +4470,17 @@ LocalProcessControlFile(bool reset) } /* + * Get the wal_level from the control file. For a standby, this value should be + * considered as its active wal_level, because it may be different from what + * was originally configured on standby. + */ +WalLevel +GetActiveWalLevelOnStandby(void) +{ + return ControlFile->wal_level; +} + +/* * Initialization of shared memory for XLOG */ Size |