From d502313841bf5f31d7aff629f93e09284d984fb3 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 25 Jun 2024 16:29:32 +0300 Subject: [PATCH] Fix MVCC bug with prepared xact with subxacts on standby (#8152) We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits being set incorrectly, and the subtransactions suddenly becoming visible to old snapshots when the prepared transaction was committed. To fix, update pg_subtrans with prepared transactions's subxids when starting hot standby from a shutdown checkpoint. The snapshots taken from that state need to be marked as "suboverflowed", so that we also check the pg_subtrans. Discussion: https://www.postgresql.org/message-id/6b852e98-2d49-4ca1-9e95-db419a2696e0%40iki.fi NEON: cherry-picked from the upstream thread ahead of time, to unblock https://github.com/neondatabase/neon/pull/7288. I expect this to be committed to upstream in the next few days, superseding this. NOTE: I did not include the new regression test on v15 and v14 branches, because the test would need some adapting, and we don't run the perl tests on Neon anyway. --- vendor/postgres-v14 | 2 +- vendor/postgres-v15 | 2 +- vendor/postgres-v16 | 2 +- vendor/revisions.json | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/postgres-v14 b/vendor/postgres-v14 index 4c51945a6167..aa88bd536b48 160000 --- a/vendor/postgres-v14 +++ b/vendor/postgres-v14 @@ -1 +1 @@ -Subproject commit 4c51945a6167ca06c0169e7a4ca5a8e7ffa3faba +Subproject commit aa88bd536b48b22328aac748be0dcfff760135d0 diff --git a/vendor/postgres-v15 b/vendor/postgres-v15 index e22098d86d6c..2092a6dcee79 160000 --- a/vendor/postgres-v15 +++ b/vendor/postgres-v15 @@ -1 +1 @@ -Subproject commit e22098d86d6c40276b6bd75c29133a33fb283ab6 +Subproject commit 2092a6dcee794bb0cb17471bd964690dd7c7355f diff --git a/vendor/postgres-v16 b/vendor/postgres-v16 index 9837db157837..3bf9219f6ef5 160000 --- a/vendor/postgres-v16 +++ b/vendor/postgres-v16 @@ -1 +1 @@ -Subproject commit 9837db157837fcf43ef7348be0017d3a2238cd27 +Subproject commit 3bf9219f6ef5e943393e9430872e26184e92d1c6 diff --git a/vendor/revisions.json b/vendor/revisions.json index f945ea6d730e..d48f1defec36 100644 --- a/vendor/revisions.json +++ b/vendor/revisions.json @@ -1,5 +1,5 @@ { - "v16": ["16.3", "9837db157837fcf43ef7348be0017d3a2238cd27"], - "v15": ["15.7", "e22098d86d6c40276b6bd75c29133a33fb283ab6"], - "v14": ["14.12", "4c51945a6167ca06c0169e7a4ca5a8e7ffa3faba"] + "v16": ["16.3", "3bf9219f6ef5e943393e9430872e26184e92d1c6"], + "v15": ["15.7", "2092a6dcee794bb0cb17471bd964690dd7c7355f"], + "v14": ["14.12", "aa88bd536b48b22328aac748be0dcfff760135d0"] }