Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit557433f

Browse files
Fix bug in early startup of Hot Standby with subtransactions.
When HS startup is deferred because of overflowed subtransactions, ensurethat we re-initialize KnownAssignedXids for when both existing and incomingsnapshots have non-zero qualifying xids.Fixes bug #6661 reported by Valentine Gogichashvili.Analysis and fix by Andres Freund
1 parent16222f3 commit557433f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static int KnownAssignedXidsGetAndSetXmin(TransactionId *xarray,
158158
TransactionIdxmax);
159159
staticTransactionIdKnownAssignedXidsGetOldestXmin(void);
160160
staticvoidKnownAssignedXidsDisplay(inttrace_level);
161+
staticvoidKnownAssignedXidsReset(void);
161162

162163
/*
163164
* Report shared-memory space needed by CreateSharedProcArray.
@@ -493,6 +494,11 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
493494
*/
494495
if (!running->subxid_overflow||running->xcnt==0)
495496
{
497+
/*
498+
* If we have already collected known assigned xids, we need to
499+
* throw them away before we apply the recovery snapshot.
500+
*/
501+
KnownAssignedXidsReset();
496502
standbyState=STANDBY_INITIALIZED;
497503
}
498504
else
@@ -536,7 +542,6 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
536542
* xids to subtrans. If RunningXacts is overflowed then we don't have
537543
* enough information to correctly update subtrans anyway.
538544
*/
539-
Assert(procArray->numKnownAssignedXids==0);
540545

541546
/*
542547
* Allocate a temporary array to avoid modifying the array passed as
@@ -566,6 +571,12 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
566571

567572
if (nxids>0)
568573
{
574+
if (procArray->numKnownAssignedXids!=0)
575+
{
576+
LWLockRelease(ProcArrayLock);
577+
elog(ERROR,"KnownAssignedXids is not empty");
578+
}
579+
569580
/*
570581
* Sort the array so that we can add them safely into
571582
* KnownAssignedXids.
@@ -3159,3 +3170,22 @@ KnownAssignedXidsDisplay(int trace_level)
31593170

31603171
pfree(buf.data);
31613172
}
3173+
3174+
/*
3175+
* KnownAssignedXidsReset
3176+
*Resets KnownAssignedXids to be empty
3177+
*/
3178+
staticvoid
3179+
KnownAssignedXidsReset(void)
3180+
{
3181+
/* use volatile pointer to prevent code rearrangement */
3182+
volatileProcArrayStruct*pArray=procArray;
3183+
3184+
LWLockAcquire(ProcArrayLock,LW_EXCLUSIVE);
3185+
3186+
pArray->numKnownAssignedXids=0;
3187+
pArray->tailKnownAssignedXids=0;
3188+
pArray->headKnownAssignedXids=0;
3189+
3190+
LWLockRelease(ProcArrayLock);
3191+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp