Handle logical slot conflicts on standby
Andres Freund <andres@anarazel.de>
Handle logical slot conflicts on standby During WAL replay on the standby, when a conflict with a logical slot is identified, invalidate such slots. There are two sources of conflicts: 1) Using the information added in 6af1793954e, logical slots are invalidated if required rows are removed 2) wal_level on the primary server is reduced to below logical Uses the infrastructure introduced in the prior commit. FIXME: add commit reference. Change InvalidatePossiblyObsoleteSlot() to use a recovery conflict to interrupt use of a slot, if called in the startup process. The new recovery conflict is added to pg_stat_database_conflicts, as confl_active_logicalslot. See 6af1793954e for an overall design of logical decoding on a standby. Bumps catversion for the addition of the pg_stat_database_conflicts column. Bumps PGSTAT_FILE_FORMAT_ID for the same reason. Author: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com> Author: Andres Freund <andres@anarazel.de> Author: Amit Khandekar <amitdkhan.pg@gmail.com> (in an older version) Reviewed-by: "Drouvot, Bertrand" <bertranddrouvot.pg@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/20230407075009.igg7be27ha2htkbt@awork3.anarazel.de
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/monitoring.sgml | modified | +11 −0 |
| src/backend/access/gist/gistxlog.c | modified | +2 −0 |
| src/backend/access/hash/hash_xlog.c | modified | +1 −0 |
| src/backend/access/heap/heapam.c | modified | +3 −0 |
| src/backend/access/nbtree/nbtxlog.c | modified | +2 −0 |
| src/backend/access/spgist/spgxlog.c | modified | +1 −0 |
| src/backend/access/transam/xlog.c | modified | +15 −0 |
| src/backend/catalog/system_views.sql | modified | +2 −1 |
| src/backend/replication/slot.c | modified | +7 −1 |
| src/backend/storage/ipc/procsignal.c | modified | +3 −0 |
| src/backend/storage/ipc/standby.c | modified | +19 −1 |
| src/backend/tcop/postgres.c | modified | +9 −0 |
| src/backend/utils/activity/pgstat_database.c | modified | +4 −0 |
| src/backend/utils/adt/pgstatfuncs.c | modified | +3 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +5 −0 |
| src/include/pgstat.h | modified | +2 −1 |
| src/include/storage/procsignal.h | modified | +1 −0 |
| src/include/storage/standby.h | modified | +2 −0 |
| src/test/regress/expected/rules.out | modified | +2 −1 |
Documentation touched
Discussion
- Minimal logical decoding on standbys 360 messages · 2018-12-12 → 2023-04-12