v4-0006-wait_event_arg-expose-buffer-for-Buffer-type-wait.patch
text/x-patch
Filename: v4-0006-wait_event_arg-expose-buffer-for-Buffer-type-wait.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v4-0006
Subject: wait_event_arg: expose buffer# for Buffer-type wait events
| File | + | − |
|---|---|---|
| src/backend/storage/buffer/bufmgr.c | 8 | 3 |
| src/backend/utils/activity/wait_event_names.txt | 6 | 5 |
From 43c9a437a61970216f97ed6161c04da48a1a505f Mon Sep 17 00:00:00 2001 From: Jakub Wartak <jakub.wartak@enterprisedb.com> Date: Wed, 11 Feb 2026 15:01:17 +0100 Subject: [PATCH v4 6/6] wait_event_arg: expose buffer# for Buffer-type wait events --- src/backend/storage/buffer/bufmgr.c | 11 ++++++++--- src/backend/utils/activity/wait_event_names.txt | 11 ++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 92c924bc64e..52f54b191c4 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -5831,7 +5831,9 @@ BufferLockAcquire(Buffer buffer, BufferDesc *buf_hdr, BufferLockMode mode) pg_unreachable(); } - pgstat_report_wait_start(wait_event); + /* Local buffers can get negative */ + pgstat_report_wait_start(wait_event | + (uint32) ((buffer>=0) ? buffer : UINT32_MAX)); /* * Wait until awakened. @@ -6643,7 +6645,9 @@ LockBufferForCleanup(Buffer buffer) SetStartupBufferPinWaitBufId(-1); } else - ProcWaitForSignal(WAIT_EVENT_BUFFER_CLEANUP); + /* Local buffers can get negative */ + ProcWaitForSignal(WAIT_EVENT_BUFFER_CLEANUP | + (uint32) ((buffer>=0) ? buffer : UINT32_MAX)); /* * Remove flag marking us as waiter. Normally this will not be set @@ -6858,7 +6862,8 @@ WaitIO(BufferDesc *buf) } /* wait on BufferDesc->cv, e.g. for concurrent synchronous IO */ - ConditionVariableSleep(cv, WAIT_EVENT_BUFFER_IO); + ConditionVariableSleep(cv, WAIT_EVENT_BUFFER_IO | + (uint32) ((buf->buf_id>=0) ? buf->buf_id : UINT32_MAX)); } ConditionVariableCancelSleep(); } diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt index b86ebd3b2c2..b1442680882 100644 --- a/src/backend/utils/activity/wait_event_names.txt +++ b/src/backend/utils/activity/wait_event_names.txt @@ -114,7 +114,7 @@ BACKUP_WAIT_WAL_ARCHIVE "Waiting for WAL files required for a backup to be succe BGWORKER_SHUTDOWN "Waiting for background worker to shut down." BGWORKER_STARTUP "Waiting for background worker to start up." BTREE_PAGE "Waiting for the page number needed to continue a parallel B-tree scan to become available." -BUFFER_IO "Waiting for buffer I/O to complete." +BUFFER_IO "Waiting for buffer I/O to complete." "Buffer# or UINT32_MAX for local(temporary) buffers." CHECKPOINT_DELAY_COMPLETE "Waiting for a backend that blocks a checkpoint from completing." CHECKPOINT_DELAY_START "Waiting for a backend that blocks a checkpoint from starting." CHECKPOINT_DONE "Waiting for a checkpoint to complete." @@ -288,10 +288,11 @@ ABI_compatibility: Section: ClassName - WaitEventBuffer -BUFFER_CLEANUP "Waiting to acquire an exclusive pin on a buffer. Buffer pin waits can be protracted if another process holds an open cursor that last read data from the buffer in question." -BUFFER_SHARED "Waiting to acquire a shared lock on a buffer." -BUFFER_SHARE_EXCLUSIVE "Waiting to acquire a share exclusive lock on a buffer." -BUFFER_EXCLUSIVE "Waiting to acquire a exclusive lock on a buffer." +BUFFER_CLEANUP "Waiting to acquire an exclusive pin on a buffer. Buffer pin waits can be protracted if another process holds an open cursor that last read data from the buffer in question." "Buffer# or UINT32_MAX for local(temporary) buffers." +BUFFER_SHARED "Waiting to acquire a shared lock on a buffer." "Buffer# or UINT32_MAX for local(temporary) buffers." +BUFFER_SHARE_EXCLUSIVE "Waiting to acquire a share exclusive lock on a buffer." "Buffer# or UINT32_MAX for local(temporary) buffers." +BUFFER_EXCLUSIVE "Waiting to acquire a exclusive lock on a buffer." "Buffer# or UINT32_MAX for local(temporary) buffers." + ABI_compatibility: -- 2.43.0