summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2016-09-09 13:11:25 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2016-09-09 13:11:25 +0100
commit1fef3d576e3a8ac69f90faf192997858f1d82f64 (patch)
treed4eb06a491b10c9d2f5e38e3578998b4e42bd8ec /src
parent1fa42debe676146f1f3e4809ef42e9a0f300e112 (diff)
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.c10
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];