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

Commit5e6368b

Browse files
committed
Wake up for latches in CheckpointWriteDelay().
The checkpointer shouldn't ignore its latch. Other backends may bewaiting for it to drain the request queue. Hopefully real systems don'thave a full queue often, but the condition is reached easily whenshared_buffers is small.This involves defining a new wait event, which will appear in thepg_stat_activity view often due to spread checkpoints.Back-patch only to 14. Even though the problem exists in earlierbranches too, it's hard to hit there. In 14 we stopped using signalhandlers for latches on Linux, *BSD and macOS, which were previouslyhiding this problem by interrupting the sleep (though not reliably, asthe signal could arrive before the sleep begins; precisely the problemlatches address).Reported-by: Andres Freund <andres@anarazel.de>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20220226213942.nb7uvb2pamyu26dj%40alap3.anarazel.de
1 parenta56e7b6 commit5e6368b

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
22352235
<entry><literal>BaseBackupThrottle</literal></entry>
22362236
<entry>Waiting during base backup when throttling activity.</entry>
22372237
</row>
2238+
<row>
2239+
<entry><literal>CheckpointerWriteDelay</literal></entry>
2240+
<entry>Waiting between writes while performing a checkpoint.</entry>
2241+
</row>
22382242
<row>
22392243
<entry><literal>PgSleep</literal></entry>
22402244
<entry>Waiting due to a call to <function>pg_sleep</function> or

‎src/backend/postmaster/checkpointer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ CheckpointerMain(void)
484484
}
485485

486486
ckpt_active= false;
487+
488+
/* We may have received an interrupt during the checkpoint. */
489+
HandleCheckpointerInterrupts();
487490
}
488491

489492
/* Check for archive_timeout and switch xlog files if necessary. */
@@ -726,7 +729,10 @@ CheckpointWriteDelay(int flags, double progress)
726729
* Checkpointer and bgwriter are no longer related so take the Big
727730
* Sleep.
728731
*/
729-
pg_usleep(100000L);
732+
WaitLatch(MyLatch,WL_LATCH_SET |WL_EXIT_ON_PM_DEATH |WL_TIMEOUT,
733+
100,
734+
WAIT_EVENT_CHECKPOINT_WRITE_DELAY);
735+
ResetLatch(MyLatch);
730736
}
731737
elseif (--absorb_counter <=0)
732738
{

‎src/backend/utils/activity/wait_event.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ pgstat_get_wait_timeout(WaitEventTimeout w)
485485
caseWAIT_EVENT_BASE_BACKUP_THROTTLE:
486486
event_name="BaseBackupThrottle";
487487
break;
488+
caseWAIT_EVENT_CHECKPOINT_WRITE_DELAY:
489+
event_name="CheckpointWriteDelay";
490+
break;
488491
caseWAIT_EVENT_PG_SLEEP:
489492
event_name="PgSleep";
490493
break;

‎src/include/utils/wait_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ typedef enum
141141
typedefenum
142142
{
143143
WAIT_EVENT_BASE_BACKUP_THROTTLE=PG_WAIT_TIMEOUT,
144+
WAIT_EVENT_CHECKPOINT_WRITE_DELAY,
144145
WAIT_EVENT_PG_SLEEP,
145146
WAIT_EVENT_RECOVERY_APPLY_DELAY,
146147
WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp