Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1fef3d5

Browse files
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
1 parent 1fa42de commit 1fef3d5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/access/transam/twophase.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,9 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
17581758
* need to hold a lock while examining it. We still acquire the
17591759
* lock to modify it, though.
17601760
*/
1761-
subxids = (TransactionId *)
1762-
(buf + MAXALIGN(sizeof(TwoPhaseFileHeader)));
1761+
subxids = (TransactionId *) (buf +
1762+
MAXALIGN(sizeof(TwoPhaseFileHeader)) +
1763+
MAXALIGN(hdr->gidlen));
17631764
for (i = 0; i < hdr->nsubxacts; i++)
17641765
{
17651766
TransactionId subxid = subxids[i];
@@ -1877,8 +1878,9 @@ StandbyRecoverPreparedTransactions(bool overwriteOK)
18771878
* Examine subtransaction XIDs ... they should all follow main
18781879
* XID.
18791880
*/
1880-
subxids = (TransactionId *)
1881-
(buf + MAXALIGN(sizeof(TwoPhaseFileHeader)));
1881+
subxids = (TransactionId *) (buf +
1882+
MAXALIGN(sizeof(TwoPhaseFileHeader)) +
1883+
MAXALIGN(hdr->gidlen));
18821884
for (i = 0; i < hdr->nsubxacts; i++)
18831885
{
18841886
TransactionId subxid = subxids[i];

0 commit comments

Comments
 (0)