]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix bug in following update chain when locking a heap tuple
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 23 Dec 2025 11:37:16 +0000 (13:37 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 23 Dec 2025 11:37:25 +0000 (13:37 +0200)
commitbb87d7fef1031b03e7595c05ef83f38d1df29028
treee1ceb1335cdb1150ca4a3a270c226c6b19a5bf0e
parent4c9f262ba81d689cfac52e6f33f39271d7c76a31
Fix bug in following update chain when locking a heap tuple

After waiting for a concurrent updater to finish, heap_lock_tuple()
followed the update chain to lock all tuple versions. However, when
stepping from the initial tuple to the next one, it failed to check
that the next tuple's XMIN matches the initial tuple's XMAX. That's an
important check whenever following an update chain, and the recursive
part that follows the chain did it, but the initial step missed it.
Without the check, if the updating transaction aborts, the updated
tuple is vacuumed away and replaced by an unrelated tuple, the
unrelated tuple might get incorrectly locked.

Author: Jasper Smit <jasper.smit@servicenow.com>
Discussion: https://www.postgresql.org/message-id/CAOG+RQ74x0q=kgBBQ=mezuvOeZBfSxM1qu_o0V28bwDz3dHxLw@mail.gmail.com
Backpatch-through: 14
src/backend/access/heap/heapam.c
src/test/modules/injection_points/Makefile
src/test/modules/injection_points/expected/heap_lock_update.out [new file with mode: 0644]
src/test/modules/injection_points/meson.build
src/test/modules/injection_points/specs/heap_lock_update.spec [new file with mode: 0644]