pgsql: Fix bug in following update chain when locking a heap tuple - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix bug in following update chain when locking a heap tuple
Date
Msg-id E1vY1Aq-002FRJ-2Q@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3e3a80f62c09709de899cc7649f1c86c63b78981

Modified Files
--------------
src/backend/access/heap/heapam.c                   |  48 ++++++---
src/test/modules/injection_points/Makefile         |   5 +-
.../injection_points/expected/heap_lock_update.out |  83 +++++++++++++++
src/test/modules/injection_points/meson.build      |   1 +
.../injection_points/specs/heap_lock_update.spec   | 117 +++++++++++++++++++++
5 files changed, 238 insertions(+), 16 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: Add missing .gitignore for src/test/modules/test_cloexec.
Next
From: Masahiko Sawada
Date:
Subject: pgsql: Toggle logical decoding dynamically based on logical slot presen