]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Reset properly snapshot export state during transaction abort
authorMichael Paquier <michael@paquier.xyz>
Mon, 18 Oct 2021 02:57:07 +0000 (11:57 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 18 Oct 2021 02:57:07 +0000 (11:57 +0900)
commitf49bf8263459bcaf253ffa33b77648b69fb2bfed
treee42430c2e484a88b55fc21a2a119f6afe7e061ae
parentae6abeb88047d689e6525a5725cffcd8fc43fe27
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
src/backend/access/transam/xact.c
src/backend/replication/logical/snapbuild.c
src/include/replication/snapbuild.h