postgresql/src/backend/replication/logical
Andres Freund 2bef06d516 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
..
decode.c Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
launcher.c Silence compiler warning induced by commit de4389712. 2017-04-26 14:01:26 -04:00
logical.c Preserve required !catalog tuples while computing initial decoding snapshot. 2017-04-27 13:13:36 -07:00
logicalfuncs.c Teach xlogreader to follow timeline switches 2017-03-22 07:05:12 +00:00
Makefile Logical replication support for initial data copy 2017-03-23 08:55:37 -04:00
message.c Spelling fixes in code comments 2017-04-26 12:07:11 -04:00
origin.c Spelling fixes in code comments 2017-04-26 12:07:11 -04:00
proto.c Spelling fixes in code comments 2017-04-26 12:07:11 -04:00
relation.c Initialize all memory for logical replication relation cache. 2017-04-23 15:54:41 -07:00
reorderbuffer.c Fix new warnings from GCC 7 2017-04-17 13:59:46 -04:00
snapbuild.c Preserve required !catalog tuples while computing initial decoding snapshot. 2017-04-27 13:13:36 -07:00
tablesync.c Fix query that gets remote relation info 2017-04-26 12:07:22 -04:00
worker.c Fix typo in comment 2017-04-26 21:13:01 -04:00