From: Heikki Linnakangas Date: Tue, 9 Dec 2025 15:06:40 +0000 (+0200) Subject: Add wait event for the group commit delay before WAL flush X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3cb5808bd11c5a7ef697922335f7642f643a4e7f;p=postgresql.git Add wait event for the group commit delay before WAL flush Author: Rafia Sabih Reviewed-by: Sami Imseih Discussion: https://www.postgresql.org/message-id/CA%2BFpmFf-hWXtrC0Q3Cr_Xo78zuP_M_VC5xgWPOYOkwqOD0T8eg@mail.gmail.com --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 6ced1d57282..fb05e8e136d 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2884,7 +2884,9 @@ XLogFlush(XLogRecPtr record) if (CommitDelay > 0 && enableFsync && MinimumActiveBackends(CommitSiblings)) { + pgstat_report_wait_start(WAIT_EVENT_COMMIT_DELAY); pg_usleep(CommitDelay); + pgstat_report_wait_end(); /* * Re-check how far we can now flush the WAL. It's generally not diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt index 1e5e368a5dc..f39830dbb34 100644 --- a/src/backend/utils/activity/wait_event_names.txt +++ b/src/backend/utils/activity/wait_event_names.txt @@ -175,6 +175,7 @@ Section: ClassName - WaitEventTimeout BASE_BACKUP_THROTTLE "Waiting during base backup when throttling activity." CHECKPOINT_WRITE_DELAY "Waiting between writes while performing a checkpoint." +COMMIT_DELAY "Waiting for commit delay before WAL flush." PG_SLEEP "Waiting due to a call to pg_sleep or a sibling function." RECOVERY_APPLY_DELAY "Waiting to apply WAL during recovery because of a delay setting." RECOVERY_RETRIEVE_RETRY_INTERVAL "Waiting during recovery when WAL data is not available from any source (pg_wal, archive or stream)."