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

Commit7bc76d5

Browse files
Check RecoveryInProgress() while holding ProcArrayLock during snapshots.
This prevents a rare, yet possible race condition at the exact momentof transition from recovery to normal running.
1 parent39bf463 commit7bc76d5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.63 2010/04/18 18:05:55 sriggs Exp $
40+
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.64 2010/04/19 18:03:38 sriggs Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -1074,8 +1074,6 @@ GetSnapshotData(Snapshot snapshot)
10741074
errmsg("out of memory")));
10751075
}
10761076

1077-
snapshot->takenDuringRecovery=RecoveryInProgress();
1078-
10791077
/*
10801078
* It is sufficient to get shared lock on ProcArrayLock, even if we are
10811079
* going to set MyProc->xmin.
@@ -1091,8 +1089,15 @@ GetSnapshotData(Snapshot snapshot)
10911089
globalxmin=xmin=xmax;
10921090

10931091
/*
1094-
* If in recovery get any known assigned xids.
1092+
* If we're in recovery then snapshot data comes from a different place,
1093+
* so decide which route we take before grab the lock. It is possible
1094+
* for recovery to end before we finish taking snapshot, and for newly
1095+
* assigned transaction ids to be added to the procarray. Xmax cannot
1096+
* change while we hold ProcArrayLock, so those newly added transaction
1097+
* ids would be filtered away, so we need not be concerned about them.
10951098
*/
1099+
snapshot->takenDuringRecovery=RecoveryInProgress();
1100+
10961101
if (!snapshot->takenDuringRecovery)
10971102
{
10981103
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp