postgresql/src/include/replication
Andres Freund 28afff347a 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.
2017-04-27 13:13:36 -07:00
..
basebackup.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
decode.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
logical.h Preserve required !catalog tuples while computing initial decoding snapshot. 2017-04-27 13:13:36 -07:00
logicalfuncs.h Generic Messages for Logical Decoding 2016-04-06 10:05:41 +01:00
message.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
origin.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
output_plugin.h Formatting and docs corrections for logical decoding output plugins. 2017-02-15 18:15:47 -05:00
reorderbuffer.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
slot.h Fix thinko in comment 2016-05-02 16:46:42 -03:00
snapbuild.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
syncrep.h Clean up parsing of synchronous_standby_names GUC variable. 2016-04-27 17:55:25 -04:00
walreceiver.h Add conninfo to pg_stat_wal_receiver 2016-06-29 16:57:17 -04:00
walsender.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
walsender_private.h Update copyright for 2016 2016-01-02 13:33:40 -05:00