]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid update conflict out serialization anomalies.
authorPeter Geoghegan <pg@bowt.ie>
Thu, 11 Jun 2020 17:09:35 +0000 (10:09 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Thu, 11 Jun 2020 17:09:35 +0000 (10:09 -0700)
commite81dc2b7e2c49fa2bb647ce562a8fd3cbbf51e0b
tree956213088b06966e22d73320faf7e6058eed0c7a
parentfb024f46369b614eb7f12bc9e097b60884a44684
Avoid update conflict out serialization anomalies.

SSI's HeapCheckForSerializableConflictOut() test failed to correctly
handle conditions involving a concurrently inserted tuple which is later
concurrently updated by a separate transaction .  A SELECT statement
that called HeapCheckForSerializableConflictOut() could end up using the
same XID (updater's XID) for both the original tuple, and the successor
tuple, missing the XID of the xact that created the original tuple
entirely.  This only happened when neither tuple from the chain was
visible to the transaction's MVCC snapshot.

The observable symptoms of this bug were subtle.  A pair of transactions
could commit, with the later transaction failing to observe the effects
of the earlier transaction (because of the confusion created by the
update to the non-visible row).  This bug dates all the way back to
commit dafaa3ef, which added SSI.

To fix, make sure that we check the xmin of concurrently inserted tuples
that happen to also have been updated concurrently.

Author: Peter Geoghegan
Reported-By: Kyle Kingsbury
Reviewed-By: Thomas Munro
Discussion: https://postgr.es/m/db7b729d-0226-d162-a126-8a8ab2dc4443@jepsen.io
Backpatch: All supported versions
src/backend/storage/lmgr/predicate.c
src/test/isolation/expected/update-conflict-out.out [new file with mode: 0644]
src/test/isolation/isolation_schedule
src/test/isolation/specs/update-conflict-out.spec [new file with mode: 0644]