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

Commit78c0f85

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 parentd9f7ad5 commit78c0f85

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,6 +2223,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
22232223
<entry><literal>BaseBackupThrottle</literal></entry>
22242224
<entry>Waiting during base backup when throttling activity.</entry>
22252225
</row>
2226+
<row>
2227+
<entry><literal>CheckpointerWriteDelay</literal></entry>
2228+
<entry>Waiting between writes while performing a checkpoint.</entry>
2229+
</row>
22262230
<row>
22272231
<entry><literal>PgSleep</literal></entry>
22282232
<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
@@ -490,6 +490,9 @@ CheckpointerMain(void)
490490
}
491491

492492
ckpt_active= false;
493+
494+
/* We may have received an interrupt during the checkpoint. */
495+
HandleCheckpointerInterrupts();
493496
}
494497

495498
/* Check for archive_timeout and switch xlog files if necessary. */
@@ -732,7 +735,10 @@ CheckpointWriteDelay(int flags, double progress)
732735
* Checkpointer and bgwriter are no longer related so take the Big
733736
* Sleep.
734737
*/
735-
pg_usleep(100000L);
738+
WaitLatch(MyLatch,WL_LATCH_SET |WL_EXIT_ON_PM_DEATH |WL_TIMEOUT,
739+
100,
740+
WAIT_EVENT_CHECKPOINT_WRITE_DELAY);
741+
ResetLatch(MyLatch);
736742
}
737743
elseif (--absorb_counter <=0)
738744
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ pgstat_get_wait_timeout(WaitEventTimeout w)
473473
caseWAIT_EVENT_BASE_BACKUP_THROTTLE:
474474
event_name="BaseBackupThrottle";
475475
break;
476+
caseWAIT_EVENT_CHECKPOINT_WRITE_DELAY:
477+
event_name="CheckpointWriteDelay";
478+
break;
476479
caseWAIT_EVENT_PG_SLEEP:
477480
event_name="PgSleep";
478481
break;

‎src/include/utils/wait_event.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ typedef enum
140140
WAIT_EVENT_PG_SLEEP,
141141
WAIT_EVENT_RECOVERY_APPLY_DELAY,
142142
WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL,
143-
WAIT_EVENT_VACUUM_DELAY
143+
WAIT_EVENT_VACUUM_DELAY,
144+
WAIT_EVENT_CHECKPOINT_WRITE_DELAY
144145
}WaitEventTimeout;
145146

146147
/* ----------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp