aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2016-09-09 11:55:12 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2016-09-09 11:55:12 +0100
commitec253de1fd2e6002122de80815ac5b963af8277c (patch)
tree275bba29efce127e862f54cd61de7d7e69d3c4d6
parentf66472428a51fc484bc5ca81791924d06a6f096d (diff)
downloadpostgresql-ec253de1fd2e6002122de80815ac5b963af8277c.tar.gz
postgresql-ec253de1fd2e6002122de80815ac5b963af8277c.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
-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];