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
This commit is contained in:
parent
994d76707a
commit
c963e84fb8
@ -1074,6 +1074,9 @@ StartPrepare(GlobalTransaction gxact)
|
|||||||
hdr.ninvalmsgs = xactGetCommittedInvalidationMessages(&invalmsgs,
|
hdr.ninvalmsgs = xactGetCommittedInvalidationMessages(&invalmsgs,
|
||||||
&hdr.initfileinval);
|
&hdr.initfileinval);
|
||||||
hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
|
hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
|
||||||
|
/* EndPrepare will fill the origin data, if necessary */
|
||||||
|
hdr.origin_lsn = InvalidXLogRecPtr;
|
||||||
|
hdr.origin_timestamp = 0;
|
||||||
|
|
||||||
save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
|
save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
|
||||||
save_state_data(gxact->gid, hdr.gidlen);
|
save_state_data(gxact->gid, hdr.gidlen);
|
||||||
@ -1133,11 +1136,6 @@ EndPrepare(GlobalTransaction gxact)
|
|||||||
hdr->origin_lsn = replorigin_session_origin_lsn;
|
hdr->origin_lsn = replorigin_session_origin_lsn;
|
||||||
hdr->origin_timestamp = replorigin_session_origin_timestamp;
|
hdr->origin_timestamp = replorigin_session_origin_timestamp;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
hdr->origin_lsn = InvalidXLogRecPtr;
|
|
||||||
hdr->origin_timestamp = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the data size exceeds MaxAllocSize, we won't be able to read it in
|
* If the data size exceeds MaxAllocSize, we won't be able to read it in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user