diff options
| author | Michael Paquier | 2023-07-03 02:01:02 +0000 |
|---|---|---|
| committer | Michael Paquier | 2023-07-03 02:01:02 +0000 |
| commit | 2aeaf80e578ed48af88d54caf2ffcf7ca62617e8 (patch) | |
| tree | a322df445b8663e7e6dbbaa970ae856d40d36902 /src/backend | |
| parent | 8c12838001c2d974d3608fe55c228f601818a729 (diff) | |
Refactor some code related to wait events "BufferPin" and "Extension"
The following changes are done:
- Addition of WaitEventBufferPin and WaitEventExtension, that hold a
list of wait events related to each category.
- Addition of two functions that encapsulate the list of wait events for
each category.
- Rename BUFFER_PIN to BUFFERPIN (only this wait event class used an
underscore, requiring a specific rule in the automation script).
These changes make a bit easier the automatic generation of all the code
and documentation related to wait events, as all the wait event
categories are now controlled by consistent structures and functions.
Author: Bertrand Drouvot
Discussion: https://postgr.es/m/c6f35117-4b20-4c78-1df5-d3056010dcf5@gmail.com
Discussion: https://postgr.es/m/77a86b3a-c4a8-5f5d-69b9-d70bbf2e9b98@gmail.com
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/storage/buffer/bufmgr.c | 2 | ||||
| -rw-r--r-- | src/backend/storage/ipc/standby.c | 2 | ||||
| -rw-r--r-- | src/backend/utils/activity/wait_event.c | 66 |
3 files changed, 62 insertions, 8 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 3c59bbd04ea..a7e3b9bb1d3 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4901,7 +4901,7 @@ LockBufferForCleanup(Buffer buffer) SetStartupBufferPinWaitBufId(-1); } else - ProcWaitForSignal(PG_WAIT_BUFFER_PIN); + ProcWaitForSignal(WAIT_EVENT_BUFFER_PIN); /* * Remove flag marking us as waiter. Normally this will not be set diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c index 4c06741a69f..cc22d2e87cc 100644 --- a/src/backend/storage/ipc/standby.c +++ b/src/backend/storage/ipc/standby.c @@ -840,7 +840,7 @@ ResolveRecoveryConflictWithBufferPin(void) * SIGHUP signal handler, etc cannot do that because it uses the different * latch from that ProcWaitForSignal() waits on. */ - ProcWaitForSignal(PG_WAIT_BUFFER_PIN); + ProcWaitForSignal(WAIT_EVENT_BUFFER_PIN); if (got_standby_delay_timeout) SendRecoveryConflictWithBufferPin(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN); diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c index 7940d646392..8572cf169ea 100644 --- a/src/backend/utils/activity/wait_event.c +++ b/src/backend/utils/activity/wait_event.c @@ -28,7 +28,9 @@ static const char *pgstat_get_wait_activity(WaitEventActivity w); +static const char *pgstat_get_wait_bufferpin(WaitEventBufferPin w); static const char *pgstat_get_wait_client(WaitEventClient w); +static const char *pgstat_get_wait_extension(WaitEventExtension w); static const char *pgstat_get_wait_ipc(WaitEventIPC w); static const char *pgstat_get_wait_timeout(WaitEventTimeout w); static const char *pgstat_get_wait_io(WaitEventIO w); @@ -90,7 +92,7 @@ pgstat_get_wait_event_type(uint32 wait_event_info) case PG_WAIT_LOCK: event_type = "Lock"; break; - case PG_WAIT_BUFFER_PIN: + case PG_WAIT_BUFFERPIN: event_type = "BufferPin"; break; case PG_WAIT_ACTIVITY: @@ -147,9 +149,13 @@ pgstat_get_wait_event(uint32 wait_event_info) case PG_WAIT_LOCK: event_name = GetLockNameFromTagType(eventId); break; - case PG_WAIT_BUFFER_PIN: - event_name = "BufferPin"; - break; + case PG_WAIT_BUFFERPIN: + { + WaitEventBufferPin w = (WaitEventBufferPin) wait_event_info; + + event_name = pgstat_get_wait_bufferpin(w); + break; + } case PG_WAIT_ACTIVITY: { WaitEventActivity w = (WaitEventActivity) wait_event_info; @@ -165,8 +171,12 @@ pgstat_get_wait_event(uint32 wait_event_info) break; } case PG_WAIT_EXTENSION: - event_name = "Extension"; - break; + { + WaitEventExtension w = (WaitEventExtension) wait_event_info; + + event_name = pgstat_get_wait_extension(w); + break; + } case PG_WAIT_IPC: { WaitEventIPC w = (WaitEventIPC) wait_event_info; @@ -255,6 +265,28 @@ pgstat_get_wait_activity(WaitEventActivity w) } /* ---------- + * pgstat_get_wait_bufferpin() - + * + * Convert WaitEventBufferPin to string. + * ---------- + */ +static const char * +pgstat_get_wait_bufferpin(WaitEventBufferPin w) +{ + const char *event_name = "unknown wait event"; + + switch (w) + { + case WAIT_EVENT_BUFFER_PIN: + event_name = "BufferPin"; + break; + /* no default case, so that compiler will warn */ + } + + return event_name; +} + +/* ---------- * pgstat_get_wait_client() - * * Convert WaitEventClient to string. @@ -298,6 +330,28 @@ pgstat_get_wait_client(WaitEventClient w) } /* ---------- + * pgstat_get_wait_extension() - + * + * Convert WaitEventExtension to string. + * ---------- + */ +static const char * +pgstat_get_wait_extension(WaitEventExtension w) +{ + const char *event_name = "unknown wait event"; + + switch (w) + { + case WAIT_EVENT_EXTENSION: + event_name = "Extension"; + break; + /* no default case, so that compiler will warn */ + } + + return event_name; +} + +/* ---------- * pgstat_get_wait_ipc() - * * Convert WaitEventIPC to string. |
