PostgreSQL Source Code git master
Loading...
Searching...
No Matches
wait_event.h File Reference
#include "utils/wait_event_types.h"
Include dependency graph for wait_event.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const charpgstat_get_wait_event (uint32 wait_event_info)
 
const charpgstat_get_wait_event_type (uint32 wait_event_info)
 
static void pgstat_report_wait_start (uint32 wait_event_info)
 
static void pgstat_report_wait_end (void)
 
void pgstat_set_wait_event_storage (uint32 *wait_event_info)
 
void pgstat_reset_wait_event_storage (void)
 
uint32 WaitEventExtensionNew (const char *wait_event_name)
 
uint32 WaitEventInjectionPointNew (const char *wait_event_name)
 
char ** GetWaitEventCustomNames (uint32 classId, int *nwaitevents)
 

Variables

PGDLLIMPORT uint32my_wait_event_info
 

Function Documentation

◆ GetWaitEventCustomNames()

char ** GetWaitEventCustomNames ( uint32  classId,
int nwaitevents 
)
extern

Definition at line 276 of file wait_event.c.

277{
278 char **waiteventnames;
281 int index;
282 int els;
283
285
286 /* Now we can safely count the number of entries */
288
289 /* Allocate enough space for all entries */
291
292 /* Now scan the hash table to copy the data */
294
295 index = 0;
297 {
298 if ((hentry->wait_event_info & WAIT_EVENT_CLASS_MASK) != classId)
299 continue;
300 waiteventnames[index] = pstrdup(hentry->wait_event_name);
301 index++;
302 }
303
305
307 return waiteventnames;
308}
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition dynahash.c:1352
int64 hash_get_num_entries(HTAB *hashp)
Definition dynahash.c:1273
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition dynahash.c:1317
#define palloc_array(type, count)
Definition fe_memutils.h:91
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1150
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1767
@ LW_SHARED
Definition lwlock.h:105
char * pstrdup(const char *in)
Definition mcxt.c:1910
static int fb(int x)
Definition type.h:97
static HTAB * WaitEventCustomHashByName
Definition wait_event.c:64
#define WAIT_EVENT_CLASS_MASK
Definition wait_event.c:43

References fb(), hash_get_num_entries(), hash_seq_init(), hash_seq_search(), LW_SHARED, LWLockAcquire(), LWLockRelease(), palloc_array, pstrdup(), WAIT_EVENT_CLASS_MASK, and WaitEventCustomHashByName.

Referenced by pg_get_wait_events().

◆ pgstat_get_wait_event()

const char * pgstat_get_wait_event ( uint32  wait_event_info)
extern

Definition at line 401 of file wait_event.c.

402{
403 uint32 classId;
405 const char *event_name;
406
407 /* report process as not waiting. */
408 if (wait_event_info == 0)
409 return NULL;
410
411 classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
412 eventId = wait_event_info & WAIT_EVENT_ID_MASK;
413
414 switch (classId)
415 {
416 case PG_WAIT_LWLOCK:
418 break;
419 case PG_WAIT_LOCK:
421 break;
424 event_name = GetWaitEventCustomIdentifier(wait_event_info);
425 break;
426 case PG_WAIT_BUFFER:
427 {
428 WaitEventBuffer w = (WaitEventBuffer) wait_event_info;
429
431 break;
432 }
433 case PG_WAIT_ACTIVITY:
434 {
435 WaitEventActivity w = (WaitEventActivity) wait_event_info;
436
438 break;
439 }
440 case PG_WAIT_CLIENT:
441 {
442 WaitEventClient w = (WaitEventClient) wait_event_info;
443
445 break;
446 }
447 case PG_WAIT_IPC:
448 {
449 WaitEventIPC w = (WaitEventIPC) wait_event_info;
450
452 break;
453 }
454 case PG_WAIT_TIMEOUT:
455 {
456 WaitEventTimeout w = (WaitEventTimeout) wait_event_info;
457
459 break;
460 }
461 case PG_WAIT_IO:
462 {
463 WaitEventIO w = (WaitEventIO) wait_event_info;
464
466 break;
467 }
468 default:
469 event_name = "unknown wait event";
470 break;
471 }
472
473 return event_name;
474}
uint16_t uint16
Definition c.h:682
uint32_t uint32
Definition c.h:683
const char * GetLockNameFromTagType(uint16 locktag_type)
Definition lmgr.c:1346
const char * GetLWLockIdentifier(uint32 classId, uint16 eventId)
Definition lwlock.c:747
#define PG_WAIT_TIMEOUT
#define PG_WAIT_INJECTIONPOINT
#define PG_WAIT_LWLOCK
#define PG_WAIT_BUFFER
#define PG_WAIT_IPC
#define PG_WAIT_CLIENT
#define PG_WAIT_EXTENSION
#define PG_WAIT_ACTIVITY
#define PG_WAIT_LOCK
#define PG_WAIT_IO
static const char * pgstat_get_wait_timeout(WaitEventTimeout w)
static const char * pgstat_get_wait_activity(WaitEventActivity w)
static const char * pgstat_get_wait_io(WaitEventIO w)
static const char * GetWaitEventCustomIdentifier(uint32 wait_event_info)
Definition wait_event.c:246
static const char * pgstat_get_wait_client(WaitEventClient w)
static const char * pgstat_get_wait_ipc(WaitEventIPC w)
#define WAIT_EVENT_ID_MASK
Definition wait_event.c:44
static const char * pgstat_get_wait_buffer(WaitEventBuffer w)

References fb(), GetLockNameFromTagType(), GetLWLockIdentifier(), GetWaitEventCustomIdentifier(), PG_WAIT_ACTIVITY, PG_WAIT_BUFFER, PG_WAIT_CLIENT, PG_WAIT_EXTENSION, PG_WAIT_INJECTIONPOINT, PG_WAIT_IO, PG_WAIT_IPC, PG_WAIT_LOCK, PG_WAIT_LWLOCK, PG_WAIT_TIMEOUT, pgstat_get_wait_activity(), pgstat_get_wait_buffer(), pgstat_get_wait_client(), pgstat_get_wait_io(), pgstat_get_wait_ipc(), pgstat_get_wait_timeout(), WAIT_EVENT_CLASS_MASK, and WAIT_EVENT_ID_MASK.

Referenced by pg_stat_get_activity(), and pg_stat_get_backend_wait_event().

◆ pgstat_get_wait_event_type()

const char * pgstat_get_wait_event_type ( uint32  wait_event_info)
extern

Definition at line 343 of file wait_event.c.

344{
345 uint32 classId;
346 const char *event_type;
347
348 /* report process as not waiting. */
349 if (wait_event_info == 0)
350 return NULL;
351
352 classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
353
354 switch (classId)
355 {
356 case PG_WAIT_LWLOCK:
357 event_type = "LWLock";
358 break;
359 case PG_WAIT_LOCK:
360 event_type = "Lock";
361 break;
362 case PG_WAIT_BUFFER:
363 event_type = "Buffer";
364 break;
365 case PG_WAIT_ACTIVITY:
366 event_type = "Activity";
367 break;
368 case PG_WAIT_CLIENT:
369 event_type = "Client";
370 break;
372 event_type = "Extension";
373 break;
374 case PG_WAIT_IPC:
375 event_type = "IPC";
376 break;
377 case PG_WAIT_TIMEOUT:
378 event_type = "Timeout";
379 break;
380 case PG_WAIT_IO:
381 event_type = "IO";
382 break;
384 event_type = "InjectionPoint";
385 break;
386 default:
387 event_type = "???";
388 break;
389 }
390
391 return event_type;
392}

References fb(), PG_WAIT_ACTIVITY, PG_WAIT_BUFFER, PG_WAIT_CLIENT, PG_WAIT_EXTENSION, PG_WAIT_INJECTIONPOINT, PG_WAIT_IO, PG_WAIT_IPC, PG_WAIT_LOCK, PG_WAIT_LWLOCK, PG_WAIT_TIMEOUT, and WAIT_EVENT_CLASS_MASK.

Referenced by pg_isolation_test_session_is_blocked(), pg_stat_get_activity(), pg_stat_get_backend_wait_event_type(), and WaitEventCustomNew().

◆ pgstat_report_wait_end()

static void pgstat_report_wait_end ( void  )
inlinestatic

Definition at line 83 of file wait_event.h.

84{
85 /* see pgstat_report_wait_start() */
86 *(volatile uint32 *) my_wait_event_info = 0;
87}
PGDLLIMPORT uint32 * my_wait_event_info
Definition wait_event.c:41

References my_wait_event_info.

Referenced by AbortSubTransaction(), AbortTransaction(), AddToDataDirLockFile(), ApplyLogicalMappingFile(), assign_wal_sync_method(), AutoVacLauncherMain(), BackgroundWriterMain(), basebackup_read_file(), BootStrapXLOG(), BufferLockAcquire(), CheckpointerMain(), CheckPointLogicalRewriteHeap(), clone_file(), copy_file(), CopyGetData(), CopySendEndOfRow(), CreateCheckPoint(), CreateDirAndVersionFile(), CreateLockFile(), dsm_impl_mmap(), dsm_impl_posix_resize(), ExecuteRecoveryCommand(), FileFallocate(), FilePrefetch(), FileReadV(), FileSync(), FileTruncate(), FileWriteback(), FileWriteV(), FileZero(), heap_xlog_logical_rewrite(), injection_wait(), issue_xlog_fsync(), LWLockReportWaitEnd(), perform_spin_delay(), pgaio_io_perform_synchronously(), pgarch_archiveXlog(), ProcArrayGroupClearXid(), read_relmap_file(), ReadControlFile(), readTimeLineHistory(), ReadTwoPhaseFile(), RecheckDataDirLockFile(), RecreateTwoPhaseFile(), ReorderBufferSerializeChange(), RestoreArchivedFile(), RestoreSlotFromDisk(), SaveSlotToPath(), SendTimeLineHistory(), shell_archive_file(), ShutdownAuxiliaryProcess(), SlruPhysicalReadPage(), SlruPhysicalWritePage(), SlruSyncFileTag(), SnapBuildRestoreContents(), SnapBuildSerialize(), TransactionGroupUpdateXidStatus(), update_controlfile(), vacuum_delay_point(), WaitEventSetWait(), WaitExceedsMaxStandbyDelay(), WALRead(), WalSndErrorCleanup(), WalSummarizerMain(), WalWriterMain(), write_relmap_file(), WriteControlFile(), writeTimeLineHistory(), writeTimeLineHistoryFile(), XLogFileCopy(), XLogFileInitInternal(), XLogFlush(), XLogPageRead(), XLogWalRcvWrite(), and XLogWrite().

◆ pgstat_report_wait_start()

static void pgstat_report_wait_start ( uint32  wait_event_info)
inlinestatic

Definition at line 67 of file wait_event.h.

68{
69 /*
70 * Since this is a four-byte field which is always read and written as
71 * four-bytes, updates are atomic.
72 */
73 *(volatile uint32 *) my_wait_event_info = wait_event_info;
74}

References my_wait_event_info.

Referenced by AddToDataDirLockFile(), ApplyLogicalMappingFile(), assign_wal_sync_method(), basebackup_read_file(), BootStrapXLOG(), BufferLockAcquire(), CheckPointLogicalRewriteHeap(), clone_file(), copy_file(), CopyGetData(), CopySendEndOfRow(), CreateCheckPoint(), CreateDirAndVersionFile(), CreateLockFile(), dsm_impl_mmap(), dsm_impl_posix_resize(), ExecuteRecoveryCommand(), FileFallocate(), FilePrefetch(), FileReadV(), FileSync(), FileTruncate(), FileWriteback(), FileWriteV(), FileZero(), heap_xlog_logical_rewrite(), injection_wait(), issue_xlog_fsync(), LWLockReportWaitStart(), perform_spin_delay(), pgaio_io_perform_synchronously(), ProcArrayGroupClearXid(), read_relmap_file(), ReadControlFile(), readTimeLineHistory(), ReadTwoPhaseFile(), RecheckDataDirLockFile(), RecreateTwoPhaseFile(), ReorderBufferSerializeChange(), RestoreArchivedFile(), RestoreSlotFromDisk(), SaveSlotToPath(), SendTimeLineHistory(), shell_archive_file(), SlruPhysicalReadPage(), SlruPhysicalWritePage(), SlruSyncFileTag(), SnapBuildRestoreContents(), SnapBuildSerialize(), TransactionGroupUpdateXidStatus(), update_controlfile(), vacuum_delay_point(), WaitEventSetWait(), WaitExceedsMaxStandbyDelay(), WALRead(), write_relmap_file(), WriteControlFile(), writeTimeLineHistory(), writeTimeLineHistoryFile(), XLogFileCopy(), XLogFileInitInternal(), XLogFlush(), XLogPageRead(), XLogWalRcvWrite(), and XLogWrite().

◆ pgstat_reset_wait_event_storage()

void pgstat_reset_wait_event_storage ( void  )
extern

Definition at line 331 of file wait_event.c.

332{
334}
static uint32 local_my_wait_event_info
Definition wait_event.c:40
uint32 * my_wait_event_info
Definition wait_event.c:41

References local_my_wait_event_info, and my_wait_event_info.

Referenced by AuxiliaryProcKill(), and ProcKill().

◆ pgstat_set_wait_event_storage()

void pgstat_set_wait_event_storage ( uint32 wait_event_info)
extern

Definition at line 319 of file wait_event.c.

320{
321 my_wait_event_info = wait_event_info;
322}

References my_wait_event_info.

Referenced by InitAuxiliaryProcess(), and InitProcess().

◆ WaitEventExtensionNew()

uint32 WaitEventExtensionNew ( const char wait_event_name)
extern

Definition at line 140 of file wait_event.c.

141{
142 return WaitEventCustomNew(PG_WAIT_EXTENSION, wait_event_name);
143}
static uint32 WaitEventCustomNew(uint32 classId, const char *wait_event_name)
Definition wait_event.c:152

References PG_WAIT_EXTENSION, and WaitEventCustomNew().

Referenced by connect_pg_server(), dblink_connect(), dblink_get_conn(), dblink_init(), GetConnection(), pgfdw_get_cleanup_result(), test_shm_mq_pipelined(), wait_for_workers_to_become_ready(), and worker_spi_main().

◆ WaitEventInjectionPointNew()

uint32 WaitEventInjectionPointNew ( const char wait_event_name)
extern

Definition at line 146 of file wait_event.c.

147{
148 return WaitEventCustomNew(PG_WAIT_INJECTIONPOINT, wait_event_name);
149}

References PG_WAIT_INJECTIONPOINT, and WaitEventCustomNew().

Referenced by injection_wait(), and test_aio_shmem_init().

Variable Documentation

◆ my_wait_event_info