Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick: Fix MVCC bug with prepared xact with subxacts on standby (v16) #447

Merged

Conversation

hlinnaka
Copy link
Contributor

See neondatabase/neon#8152 for the main PR in the neon repo

This went unnoticed, because only a few existing callers of
BackgroundPsql->query used the result, and the ones that did were not
bothered by an extra newline. I noticed because I was about to add a
new test that checks the result.

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
neondatabase/neon#7288. I expect this to be
committed to upstream in the next few days, superseding this.
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
neondatabase/neon#7288. I expect this to be
committed to upstream in the next few days, superseding this.
@hlinnaka hlinnaka changed the title Cherry-pick: Fix MVCC bug with prepared xact with subxacts on standby Cherry-pick: Fix MVCC bug with prepared xact with subxacts on standby (v16) Jun 25, 2024
@knizhnik knizhnik self-requested a review June 25, 2024 11:44
@hlinnaka hlinnaka merged commit d55e0ac into REL_16_STABLE_neon Jun 25, 2024
@hlinnaka hlinnaka deleted the cherry-pick-twophase-shutdown-visibility-fix-v16 branch June 25, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants