pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle logical slot conflicts on standby
Date: Sat, 08 Apr 2023 07:11:01 +0000
Message-ID: <E1pl2iy-0020Hl-7X@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/26669757b6a7665c1069e77e6472bd8550193ca6

Modified Files
--------------
doc/src/sgml/monitoring.sgml                 | 11 +++++++++++
src/backend/access/gist/gistxlog.c           |  2 ++
src/backend/access/hash/hash_xlog.c          |  1 +
src/backend/access/heap/heapam.c             |  3 +++
src/backend/access/nbtree/nbtxlog.c          |  2 ++
src/backend/access/spgist/spgxlog.c          |  1 +
src/backend/access/transam/xlog.c            | 15 +++++++++++++++
src/backend/catalog/system_views.sql         |  3 ++-
src/backend/replication/slot.c               |  8 +++++++-
src/backend/storage/ipc/procsignal.c         |  3 +++
src/backend/storage/ipc/standby.c            | 20 +++++++++++++++++++-
src/backend/tcop/postgres.c                  |  9 +++++++++
src/backend/utils/activity/pgstat_database.c |  4 ++++
src/backend/utils/adt/pgstatfuncs.c          |  3 +++
src/include/catalog/catversion.h             |  2 +-
src/include/catalog/pg_proc.dat              |  5 +++++
src/include/pgstat.h                         |  3 ++-
src/include/storage/procsignal.h             |  1 +
src/include/storage/standby.h                |  2 ++
src/test/regress/expected/rules.out          |  3 ++-
20 files changed, 95 insertions(+), 6 deletions(-)



Message-ID: <E1pl2iy-0020Hl-7X@gemulon.postgresql.org>
Permalink:  ../E1pl2iy-0020Hl-7X@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pl2iy-0020Hl-7X@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Handle logical slot conflicts on standby
  In-Reply-To: <E1pl2iy-0020Hl-7X@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox