Skip to content

Commit c963e84

Browse files
committed
Make origin data initialization consistent other fields in 2PC header
As of 1eb6d65, the origin data is optionally stored in a 2PC file header, with the data filled in EndPrepare() even in the default case where there is no origin data to add. This was inconsistent with all the other fields of TwoPhaseFileHeader which are initialized in StartPrepare(), so move the initialization of origin_lsn and origin_timestamp there instead. The effect of missing the initialization at this early stage is only cosmetic based on the current logic of the code, but could have led to issues in the long-term, and it is more consistent done this way. Reported-by: Ranier Vilela Discussion: https://postgr.es/m/CAEudQAooECJ+gU_RZB-yhioPOV94R4ucoHAf68PiJhLpgpVpBw@mail.gmail.com
1 parent 994d767 commit c963e84

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/backend/access/transam/twophase.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,9 @@ StartPrepare(GlobalTransaction gxact)
10741074
hdr.ninvalmsgs = xactGetCommittedInvalidationMessages(&invalmsgs,
10751075
&hdr.initfileinval);
10761076
hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
1077+
/* EndPrepare will fill the origin data, if necessary */
1078+
hdr.origin_lsn = InvalidXLogRecPtr;
1079+
hdr.origin_timestamp = 0;
10771080

10781081
save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
10791082
save_state_data(gxact->gid, hdr.gidlen);
@@ -1133,11 +1136,6 @@ EndPrepare(GlobalTransaction gxact)
11331136
hdr->origin_lsn = replorigin_session_origin_lsn;
11341137
hdr->origin_timestamp = replorigin_session_origin_timestamp;
11351138
}
1136-
else
1137-
{
1138-
hdr->origin_lsn = InvalidXLogRecPtr;
1139-
hdr->origin_timestamp = 0;
1140-
}
11411139

11421140
/*
11431141
* If the data size exceeds MaxAllocSize, we won't be able to read it in

0 commit comments

Comments
 (0)