pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@postgresql.org
Subject: pgsql: Preserve required !catalog tuples while computing initial decodi
Date: Thu, 27 Apr 2017 20:16:20 +0000
Message-ID: <E1d3pps-0006Tn-AT@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Preserve required !catalog tuples while computing initial decoding snapshot.

The logical decoding machinery already preserved all the required
catalog tuples, which is sufficient in the course of normal logical
decoding, but did not guarantee that non-catalog tuples were preserved
during computation of the initial snapshot when creating a slot over
the replication protocol.

This could cause a corrupted initial snapshot being exported.  The
time window for issues is usually not terribly large, but on a busy
server it's perfectly possible to it hit it.  Ongoing decoding is not
affected by this bug.

To avoid increased overhead for the SQL API, only retain additional
tuples when a logical slot is being created over the replication
protocol.  To do so this commit changes the signature of
CreateInitDecodingContext(), but it seems unlikely that it's being
used in an extension, so that's probably ok.

In a drive-by fix, fix handling of
ReplicationSlotsComputeRequiredXmin's already_locked argument, which
should only apply to ProcArrayLock, not ReplicationSlotControlLock.

Reported-By: Erik Rijkers
Analyzed-By: Petr Jelinek
Author: Petr Jelinek, heavily editorialized by Andres Freund
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/9a897b86-46e1-9915-ee4c-da02e4ff6a95@2ndquadrant.com
Backport: 9.4, where logical decoding was introduced.

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/47f896b5c2ec255d457830945d5801bfc1c67b2f

Modified Files
--------------
src/backend/replication/logical/logical.c   | 25 +++++++++++++++++--------
src/backend/replication/logical/snapbuild.c | 12 ++++++++++++
src/backend/replication/slot.c              | 25 +++++++++++++++++++++----
src/backend/replication/slotfuncs.c         |  4 ++--
src/backend/replication/walsender.c         |  1 +
src/backend/storage/ipc/procarray.c         | 14 +++++++++++---
src/include/replication/logical.h           |  1 +
src/include/storage/procarray.h             |  2 +-
8 files changed, 66 insertions(+), 18 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (4+ messages)  latest in thread

Message-ID: <E1d3pps-0006Tn-AT@gemulon.postgresql.org>
Permalink:  ../E1d3pps-0006Tn-AT@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1d3pps-0006Tn-AT@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: pgsql: Preserve required !catalog tuples while computing initial decodi
  In-Reply-To: <E1d3pps-0006Tn-AT@gemulon.postgresql.org>
  References: <E1d3pps-0006Tn-AT@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