]> granicus.if.org Git - postgresql/commit
Preserve required !catalog tuples while computing initial decoding snapshot.
authorAndres Freund <andres@anarazel.de>
Mon, 24 Apr 2017 03:41:29 +0000 (20:41 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 27 Apr 2017 20:13:36 +0000 (13:13 -0700)
commit2bef06d51646058c6bb480fcdbffb1f0cc914fed
tree6d344f49ba0b6e2e6568847214c85c13965bace2
parentfa31b6f4e9696f3c9777bf4ec2faea822826ce9f
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.
src/backend/replication/logical/logical.c
src/backend/replication/logical/snapbuild.c
src/backend/replication/slot.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/backend/storage/ipc/procarray.c
src/include/replication/logical.h
src/include/storage/procarray.h