| From: | "chee(dot)wooson" <chee(dot)wooson(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH v2] Fix exported snapshot xmin handoff race |
| Date: | 2026-07-30 04:20:14 |
| Message-ID: | 20260730042128.714201-1-chee.wooson@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Attached is v2.
Sorry that v1 was a bit noisy. This was my first PostgreSQL patch
submission, and I sent the patch series inline without realizing how much
it would expand in the archives. This version is attached as a single
patch.
Changes since v1:
- simplified the fix to take ProcArrayLock exclusively in
ProcArrayInstallImportedXmin();
- dropped the PGPROC xmin-export state machine;
- squashed the reproducer and fix into one patch;
- adjusted the TAP test to match the exclusive-lock approach.
The race is that SET TRANSACTION SNAPSHOT can install the imported xmin
while VACUUM is already in the middle of ComputeXidHorizons(), because
both paths currently hold ProcArrayLock in shared mode. VACUUM can then
miss both the importer's newly installed xmin and the source transaction's
xmin, and compute a horizon that is too new.
The attached patch changes ProcArrayInstallImportedXmin() to acquire
ProcArrayLock exclusively. This serializes exported-snapshot import with
horizon computation. The patch also adds an injection-point TAP test that
pauses VACUUM inside ComputeXidHorizons(), starts SET TRANSACTION SNAPSHOT
concurrently, and verifies that the importer waits for ProcArrayLock before
the imported snapshot is allowed to protect the deleted tuple.
Validation:
- meson test -C build --suite setup --print-errorlogs
- meson test -C build test_misc/015_export_snapshot --no-rebuild
--print-errorlogs
The new test passes with the fix, with 3 subtests passed. I also verified
that the patch applies cleanly to current master.
Regards,
Chee
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Fix-exported-snapshot-xmin-handoff-race.patch | text/x-patch | 11.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Smith | 2026-07-30 04:23:22 | Re: Support EXCEPT for TABLES IN SCHEMA publications |
| Previous Message | Denis Smirnov | 2026-07-30 04:12:39 | Re: FROM clause before SELECT |