diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2016-09-09 13:11:25 +0100 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2016-09-09 13:11:25 +0100 |
commit | 1fef3d576e3a8ac69f90faf192997858f1d82f64 (patch) | |
tree | d4eb06a491b10c9d2f5e38e3578998b4e42bd8ec /src | |
parent | 1fa42debe676146f1f3e4809ef42e9a0f300e112 (diff) | |
download | postgresql-1fef3d576e3a8ac69f90faf192997858f1d82f64.tar.gz postgresql-1fef3d576e3a8ac69f90faf192997858f1d82f64.zip |
Fix corruption of 2PC recovery with subxacts
Reading 2PC state files during recovery was borked, causing corruptions during
recovery. Effect limited to servers with 2PC, subtransactions and
recovery/replication.
Stas Kelvich, reviewed by Michael Paquier and Pavan Deolasee
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/twophase.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 1323fb508dc..5415604993a 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -1758,8 +1758,9 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p) * need to hold a lock while examining it. We still acquire the * lock to modify it, though. */ - subxids = (TransactionId *) - (buf + MAXALIGN(sizeof(TwoPhaseFileHeader))); + subxids = (TransactionId *) (buf + + MAXALIGN(sizeof(TwoPhaseFileHeader)) + + MAXALIGN(hdr->gidlen)); for (i = 0; i < hdr->nsubxacts; i++) { TransactionId subxid = subxids[i]; @@ -1877,8 +1878,9 @@ StandbyRecoverPreparedTransactions(bool overwriteOK) * Examine subtransaction XIDs ... they should all follow main * XID. */ - subxids = (TransactionId *) - (buf + MAXALIGN(sizeof(TwoPhaseFileHeader))); + subxids = (TransactionId *) (buf + + MAXALIGN(sizeof(TwoPhaseFileHeader)) + + MAXALIGN(hdr->gidlen)); for (i = 0; i < hdr->nsubxacts; i++) { TransactionId subxid = subxids[i]; |