Allow logical decoding on standbys
Andres Freund <andres@anarazel.de>
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>
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +15 −0 |
| doc/src/sgml/logicaldecoding.sgml | modified | +27 −0 |
| src/backend/access/transam/xlog.c | modified | +11 −0 |
| src/backend/access/transam/xlogfuncs.c | modified | +31 −0 |
| src/backend/catalog/system_functions.sql | modified | +2 −0 |
| src/backend/replication/logical/decode.c | modified | +29 −1 |
| src/backend/replication/logical/logical.c | modified | +20 −16 |
| src/backend/replication/slot.c | modified | +30 −27 |
| src/backend/replication/walsender.c | modified | +32 −16 |
| src/include/access/xlog.h | modified | +1 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +3 −0 |