]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix snapshot handling in logicalmsg_decode
authorTomas Vondra <tomas.vondra@postgresql.org>
Wed, 22 Feb 2023 14:24:09 +0000 (15:24 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Wed, 22 Feb 2023 14:35:19 +0000 (15:35 +0100)
commit8de91ebf2ac1e9922214bf2976a2fcc5c045c169
tree9aa8303bb5557e015e3483e980437ee52c685f7f
parent83a54d9661027cbb0a97e543ce7440d55812c87c
Fix snapshot handling in logicalmsg_decode

Whe decoding a transactional logical message, logicalmsg_decode called
SnapBuildGetOrBuildSnapshot. But we may not have a consistent snapshot
yet at that point. We don't actually need the snapshot in this case
(during replay we'll have the snapshot from the transaction), so in
practice this is harmless. But in assert-enabled build this crashes.

Fixed by requesting the snapshot only in non-transactional case, where
we are guaranteed to have SNAPBUILD_CONSISTENT.

Backpatch to 11. The issue exists since 9.6.

Backpatch-through: 11
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/84d60912-6eab-9b84-5de3-41765a5449e8@enterprisedb.com
src/backend/replication/logical/decode.c
src/backend/replication/logical/reorderbuffer.c