postgresql/src/backend/replication/logical
Michael Paquier 409f9ca447 Reset properly snapshot export state during transaction abort
During a replication slot creation, an ERROR generated in the same
transaction as the one creating a to-be-exported snapshot would have
left the backend in an inconsistent state, as the associated static
export snapshot state was not being reset on transaction abort, but only
on the follow-up command received by the WAL sender that created this
snapshot on replication slot creation.  This would trigger inconsistency
failures if this session tried to export again a snapshot, like during
the creation of a replication slot.

Note that a snapshot export cannot happen in a transaction block, so
there is no need to worry resetting this state for subtransaction
aborts.  Also, this inconsistent state would very unlikely show up to
users.  For example, one case where this could happen is an
out-of-memory error when building the initial snapshot to-be-exported.
Dilip found this problem while poking at a different patch, that caused
an error in this code path for reasons unrelated to HEAD.

Author: Dilip Kumar
Reviewed-by: Michael Paquier, Zhihong Yu
Discussion: https://postgr.es/m/CAFiTN-s0zA1Kj0ozGHwkYkHwa5U0zUE94RSc_g81WrpcETB5=w@mail.gmail.com
Backpatch-through: 9.6
2021-10-18 11:55:42 +09:00
..
decode.c Add support for prepared transactions to built-in logical replication. 2021-07-14 07:33:50 +05:30
launcher.c Optimize fileset usage in apply worker. 2021-09-02 08:13:46 +05:30
logical.c Log new catalog xmin candidate in LogicalIncreaseXminForSlot(). 2021-09-07 08:07:11 +05:30
logicalfuncs.c Remove code duplication for permission checks with replication slots 2021-09-14 10:15:49 +09:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
message.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
origin.c Fix incorrect error code in StartupReplicationOrigin(). 2021-08-30 09:14:31 +05:30
proto.c Add logical change details to logical replication worker errcontext. 2021-08-27 08:30:23 +05:30
relation.c Don't try to print data type names in slot_store_error_callback(). 2021-07-02 16:04:54 -04:00
reorderbuffer.c Add parent table name in an error in reorderbuffer.c. 2021-09-22 07:42:52 +05:30
snapbuild.c Reset properly snapshot export state during transaction abort 2021-10-18 11:55:42 +09:00
tablesync.c Add support for prepared transactions to built-in logical replication. 2021-07-14 07:33:50 +05:30
worker.c Optimize fileset usage in apply worker. 2021-09-02 08:13:46 +05:30