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

Commitd18e756

Browse files
committed
Remove CheckpointLock.
Up until now, we've held this lock when performing a checkpoint orrestartpoint, but commit076a055 backin 2004 and commit7e48b77 from 2009,taken together, have removed all need for this. In the present code,there's only ever one process entitled to attempt a checkpoint: eitherthe checkpointer, during normal operation, or the postmaster, duringsingle-user operation. So, we don't need the lock.One possible concern in making this change is that it means thata substantial amount of code where HOLD_INTERRUPTS() was previouslyin effect due to the preceding LWLockAcquire() will now berunning without that. This could mean that ProcessInterrupts()gets called in places from which it didn't before. However, thisseems unlikely to do very much, because the checkpointer doesn'thave any signal mapped to die(), so it's not clear how,for example, ProcDiePending = true could happen in the firstplace. Similarly with ClientConnectionLost and recovery conflicts.Also, if there are any such problems, we might want to fix themrather than reverting this, since running lots of code withinterrupt handling suspended is generally bad.Patch by me, per an inquiry by Amul Sul. Review by Tom Laneand Michael Paquier.Discussion:http://postgr.es/m/CAAJ_b97XnBBfYeSREDJorFsyoD1sHgqnNuCi=02mNQBUMnA=FA@mail.gmail.com
1 parent951862e commitd18e756

File tree

5 files changed

+6
-36
lines changed

5 files changed

+6
-36
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,10 +1880,6 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
18801880
<entry>Waiting to associate a data block with a buffer in the buffer
18811881
pool.</entry>
18821882
</row>
1883-
<row>
1884-
<entry><literal>Checkpoint</literal></entry>
1885-
<entry>Waiting to begin a checkpoint.</entry>
1886-
</row>
18871883
<row>
18881884
<entry><literal>CheckpointerComm</literal></entry>
18891885
<entry>Waiting to manage fsync requests.</entry>

‎src/backend/access/heap/rewriteheap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,8 @@ CheckPointLogicalRewriteHeap(void)
12561256

12571257
/*
12581258
* The file cannot vanish due to concurrency since this function
1259-
* is the only one removing logical mappings andit's run while
1260-
*CheckpointLock is held exclusively.
1259+
* is the only one removing logical mappings andonly one
1260+
*checkpoint can be in progress at a time.
12611261
*/
12621262
if (fd<0)
12631263
ereport(ERROR,

‎src/backend/access/transam/xlog.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,6 @@ static XLogRecPtr RedoStartLSN = InvalidXLogRecPtr;
430430
* ControlFileLock: must be held to read/update control file or create
431431
* new log file.
432432
*
433-
* CheckpointLock: must be held to do a checkpoint or restartpoint (ensures
434-
* only one checkpointer at a time; currently, with all checkpoints done by
435-
* the checkpointer, this is just pro forma).
436-
*
437433
*----------
438434
*/
439435

@@ -8864,14 +8860,6 @@ CreateCheckPoint(int flags)
88648860
*/
88658861
InitXLogInsert();
88668862

8867-
/*
8868-
* Acquire CheckpointLock to ensure only one checkpoint happens at a time.
8869-
* (This is just pro forma, since in the present system structure there is
8870-
* only one process that is allowed to issue checkpoints at any given
8871-
* time.)
8872-
*/
8873-
LWLockAcquire(CheckpointLock,LW_EXCLUSIVE);
8874-
88758863
/*
88768864
* Prepare to accumulate statistics.
88778865
*
@@ -8941,7 +8929,6 @@ CreateCheckPoint(int flags)
89418929
if (last_important_lsn==ControlFile->checkPoint)
89428930
{
89438931
WALInsertLockRelease();
8944-
LWLockRelease(CheckpointLock);
89458932
END_CRIT_SECTION();
89468933
ereport(DEBUG1,
89478934
(errmsg("checkpoint skipped because system is idle")));
@@ -9241,15 +9228,12 @@ CreateCheckPoint(int flags)
92419228
CheckpointStats.ckpt_segs_added,
92429229
CheckpointStats.ckpt_segs_removed,
92439230
CheckpointStats.ckpt_segs_recycled);
9244-
9245-
LWLockRelease(CheckpointLock);
92469231
}
92479232

92489233
/*
92499234
* Mark the end of recovery in WAL though without running a full checkpoint.
92509235
* We can expect that a restartpoint is likely to be in progress as we
9251-
* do this, though we are unwilling to wait for it to complete. So be
9252-
* careful to avoid taking the CheckpointLock anywhere here.
9236+
* do this, though we are unwilling to wait for it to complete.
92539237
*
92549238
* CreateRestartPoint() allows for the case where recovery may end before
92559239
* the restartpoint completes so there is no concern of concurrent behaviour.
@@ -9399,12 +9383,6 @@ CreateRestartPoint(int flags)
93999383
XLogSegNo_logSegNo;
94009384
TimestampTzxtime;
94019385

9402-
/*
9403-
* Acquire CheckpointLock to ensure only one restartpoint or checkpoint
9404-
* happens at a time.
9405-
*/
9406-
LWLockAcquire(CheckpointLock,LW_EXCLUSIVE);
9407-
94089386
/* Get a local copy of the last safe checkpoint record. */
94099387
SpinLockAcquire(&XLogCtl->info_lck);
94109388
lastCheckPointRecPtr=XLogCtl->lastCheckPointRecPtr;
@@ -9420,7 +9398,6 @@ CreateRestartPoint(int flags)
94209398
{
94219399
ereport(DEBUG2,
94229400
(errmsg("skipping restartpoint, recovery has already ended")));
9423-
LWLockRelease(CheckpointLock);
94249401
return false;
94259402
}
94269403

@@ -9455,7 +9432,6 @@ CreateRestartPoint(int flags)
94559432
UpdateControlFile();
94569433
LWLockRelease(ControlFileLock);
94579434
}
9458-
LWLockRelease(CheckpointLock);
94599435
return false;
94609436
}
94619437

@@ -9621,8 +9597,6 @@ CreateRestartPoint(int flags)
96219597
xtime ?errdetail("Last completed transaction was at log time %s.",
96229598
timestamptz_to_str(xtime)) :0));
96239599

9624-
LWLockRelease(CheckpointLock);
9625-
96269600
/*
96279601
* Finally, execute archive_cleanup_command, if any.
96289602
*/

‎src/backend/replication/logical/origin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,8 @@ CheckPointReplicationOrigin(void)
559559
tmppath)));
560560

561561
/*
562-
* no other backend can perform this at the same time, we're protected by
563-
*CheckpointLock.
562+
* no other backend can perform this at the same time; only one
563+
*checkpoint can happen at a time.
564564
*/
565565
tmpfd=OpenTransientFile(tmppath,
566566
O_CREAT |O_EXCL |O_WRONLY |PG_BINARY);

‎src/backend/storage/lmgr/lwlocknames.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ SInvalWriteLock6
1515
WALBufMappingLock7
1616
WALWriteLock8
1717
ControlFileLock9
18-
CheckpointLock10
18+
# 10 was CheckpointLock
1919
XactSLRULock11
2020
SubtransSLRULock12
2121
MultiXactGenLock13

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp