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: Allow logical decoding on standbys
Date: Sat, 08 Apr 2023 09:26:51 +0000
Message-ID: <E1pl4qQ-0021HA-Bw@gemulon.postgresql.org> (raw)

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>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0fdab27ad68a059a1663fa5ce48d76333f1bd74c

Modified Files
--------------
doc/src/sgml/func.sgml                    | 15 ++++++++
doc/src/sgml/logicaldecoding.sgml         | 27 +++++++++++++++
src/backend/access/transam/xlog.c         | 11 ++++++
src/backend/access/transam/xlogfuncs.c    | 31 +++++++++++++++++
src/backend/catalog/system_functions.sql  |  2 ++
src/backend/replication/logical/decode.c  | 30 +++++++++++++++-
src/backend/replication/logical/logical.c | 36 ++++++++++---------
src/backend/replication/slot.c            | 57 ++++++++++++++++---------------
src/backend/replication/walsender.c       | 48 +++++++++++++++++---------
src/include/access/xlog.h                 |  1 +
src/include/catalog/catversion.h          |  2 +-
src/include/catalog/pg_proc.dat           |  3 ++
12 files changed, 202 insertions(+), 61 deletions(-)



view thread (8+ messages)  latest in thread

Message-ID: <E1pl4qQ-0021HA-Bw@gemulon.postgresql.org>
Permalink:  ../E1pl4qQ-0021HA-Bw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pl4qQ-0021HA-Bw@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: Allow logical decoding on standbys
  In-Reply-To: <E1pl4qQ-0021HA-Bw@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