Skip to content

Commit ec253de

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 f664724 commit ec253de

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/backend/access/transam/twophase.c

Lines changed: 6 additions & 4 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy