Skip to content

Commit 86bc8dd

Browse files
committed
Fixpack for twophase commit
* Fix twophase files recovery (32/64 bit xid in file names) * Fix overoptimistic SubTransSetParent() in twophase.c (that's probably broken since 9.4) * Port 009_twophase.pl from pg-10 to pg-9.6
1 parent 4fc008b commit 86bc8dd

File tree

2 files changed

+445
-8
lines changed

2 files changed

+445
-8
lines changed

src/backend/access/transam/twophase.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ ParsePrepareRecord(uint8 info, char *xlrec, xl_xact_parsed_prepare *parsed)
14591459
parsed->nsubxacts = hdr->nsubxacts;
14601460
parsed->nrels = hdr->ncommitrels;
14611461
parsed->nmsgs = hdr->ninvalmsgs;
1462-
1462+
14631463
parsed->subxacts = (TransactionId *) bufptr;
14641464
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
14651465

@@ -1949,8 +1949,8 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
19491949
cldir = AllocateDir(TWOPHASE_DIR);
19501950
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
19511951
{
1952-
if (strlen(clde->d_name) == 8 &&
1953-
strspn(clde->d_name, "0123456789ABCDEF") == 8)
1952+
if (strlen(clde->d_name) == 2*sizeof(TransactionId) &&
1953+
strspn(clde->d_name, "0123456789ABCDEF") == 2*sizeof(TransactionId))
19541954
{
19551955
TransactionId xid;
19561956
char *buf;
@@ -2085,8 +2085,8 @@ StandbyRecoverPreparedTransactions(bool overwriteOK)
20852085
cldir = AllocateDir(TWOPHASE_DIR);
20862086
while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
20872087
{
2088-
if (strlen(clde->d_name) == 8 &&
2089-
strspn(clde->d_name, "0123456789ABCDEF") == 8)
2088+
if (strlen(clde->d_name) == 2*sizeof(TransactionId) &&
2089+
strspn(clde->d_name, "0123456789ABCDEF") == 2*sizeof(TransactionId))
20902090
{
20912091
TransactionId xid;
20922092
char *buf;
@@ -2170,8 +2170,8 @@ RecoverPreparedTransactions(void)
21702170
cldir = AllocateDir(dir);
21712171
while ((clde = ReadDir(cldir, dir)) != NULL)
21722172
{
2173-
if (strlen(clde->d_name) == 8 &&
2174-
strspn(clde->d_name, "0123456789ABCDEF") == 8)
2173+
if (strlen(clde->d_name) == 2*sizeof(TransactionId) &&
2174+
strspn(clde->d_name, "0123456789ABCDEF") == 2*sizeof(TransactionId))
21752175
{
21762176
TransactionId xid;
21772177
char *buf;
@@ -2226,7 +2226,7 @@ RecoverPreparedTransactions(void)
22262226
* here must match one used in AssignTransactionId().
22272227
*/
22282228
if (InHotStandby && (hdr->nsubxacts >= PGPROC_MAX_CACHED_SUBXIDS ||
2229-
XLogLogicalInfoActive()))
2229+
XLogStandbyInfoActive()))
22302230
overwriteOK = true;
22312231

22322232
/*

0 commit comments

Comments
 (0)