mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Reorder actions in ProcArrayApplyRecoveryInfo()
Since 5a1dfde8334b, 2PC filenames use FullTransactionId. Thus, it needs to convert TransactionId to FullTransactionId in StandbyTransactionIdIsPrepared() using TransamVariables->nextXid. However, ProcArrayApplyRecoveryInfo() first releases locks with usage StandbyTransactionIdIsPrepared(), then advances TransamVariables->nextXid. This sequence of actions could cause errors. This commit makes ProcArrayApplyRecoveryInfo() advance TransamVariables->nextXid before releasing locks. Reported-by: Thomas Munro, Michael Paquier Discussion: https://postgr.es/m/CA%2BhUKGLj_ve1_pNAnxwYU9rDcv7GOhsYXJt7jMKSA%3D5-6ss-Cw%40mail.gmail.com Discussion: https://postgr.es/m/Zadp9f4E1MYvMJqe%40paquier.xyz
This commit is contained in:
parent
6db4598fcb
commit
c64086b79d
@ -1053,6 +1053,7 @@ void
|
|||||||
ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
||||||
{
|
{
|
||||||
TransactionId *xids;
|
TransactionId *xids;
|
||||||
|
TransactionId xid;
|
||||||
int nxids;
|
int nxids;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1066,6 +1067,16 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
|||||||
*/
|
*/
|
||||||
ExpireOldKnownAssignedTransactionIds(running->oldestRunningXid);
|
ExpireOldKnownAssignedTransactionIds(running->oldestRunningXid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adjust TransamVariables->nextXid before StandbyReleaseOldLocks(),
|
||||||
|
* because we will need it up to date for accessing two-phase transactions
|
||||||
|
* in StandbyReleaseOldLocks().
|
||||||
|
*/
|
||||||
|
xid = running->nextXid;
|
||||||
|
TransactionIdRetreat(xid);
|
||||||
|
AdvanceNextFullTransactionIdPastXid(xid);
|
||||||
|
Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove stale locks, if any.
|
* Remove stale locks, if any.
|
||||||
*/
|
*/
|
||||||
@ -1275,11 +1286,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
|||||||
|
|
||||||
LWLockRelease(ProcArrayLock);
|
LWLockRelease(ProcArrayLock);
|
||||||
|
|
||||||
/* TransamVariables->nextXid must be beyond any observed xid. */
|
|
||||||
AdvanceNextFullTransactionIdPastXid(latestObservedXid);
|
|
||||||
|
|
||||||
Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
|
|
||||||
|
|
||||||
KnownAssignedXidsDisplay(DEBUG3);
|
KnownAssignedXidsDisplay(DEBUG3);
|
||||||
if (standbyState == STANDBY_SNAPSHOT_READY)
|
if (standbyState == STANDBY_SNAPSHOT_READY)
|
||||||
elog(DEBUG1, "recovery snapshots are now enabled");
|
elog(DEBUG1, "recovery snapshots are now enabled");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user