From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix data loss at inplace update after heap_update().
Date: Tue, 24 Sep 2024 22:27:59 +0000
Message-ID: <E1stE0k-000kin-KF@gemulon.postgresql.org> (raw)
Fix data loss at inplace update after heap_update().
As previously-added tests demonstrated, heap_inplace_update() could
instead update an unrelated tuple of the same catalog. It could lose
the update. Losing relhasindex=t was a source of index corruption.
Inplace-updating commands like VACUUM will now wait for heap_update()
commands like GRANT TABLE and GRANT DATABASE. That isn't ideal, but a
long-running GRANT already hurts VACUUM progress more just by keeping an
XID running. The VACUUM will behave like a DELETE or UPDATE waiting for
the uncommitted change.
For implementation details, start at the systable_inplace_update_begin()
header comment and README.tuplock. Back-patch to v12 (all supported
versions). In back branches, retain a deprecated heap_inplace_update(),
for extensions.
Reported by Smolkin Grigory. Reviewed by Nitin Motiani, (in earlier
versions) Heikki Linnakangas, and (in earlier versions) Alexander
Lakhin.
Discussion: https://postgr.es/m/CAMp+ueZQz3yDk7qg42hk6-9gxniYbp-=bG2mgqecErqR5gGGOA@mail.gmail.com
Branch
------
REL_12_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/7354b680ab64fbde6072f248fe3b2ff909a99d12
Modified Files
--------------
src/backend/access/heap/README.tuplock | 11 +
src/backend/access/heap/heapam.c | 248 +++++++++++++++++++--
src/backend/access/index/genam.c | 138 ++++++++++++
src/backend/catalog/index.c | 38 +---
src/backend/catalog/toasting.c | 31 ++-
src/backend/commands/dbcommands.c | 34 +--
src/backend/commands/vacuum.c | 32 ++-
src/include/access/genam.h | 9 +
src/include/access/heapam.h | 7 +
.../isolation/expected/intra-grant-inplace-db.out | 10 +-
.../isolation/expected/intra-grant-inplace.out | 16 +-
.../isolation/specs/intra-grant-inplace-db.spec | 1 -
src/test/isolation/specs/intra-grant-inplace.spec | 4 +-
13 files changed, 485 insertions(+), 94 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix data loss at inplace update after heap_update().
In-Reply-To: <E1stE0k-000kin-KF@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox