Coverage Report

Created: 2026-09-28 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/postgres/src/include/utils/wait_event.h
Line
Count
Source
1
/*-------------------------------------------------------------------------
2
 * wait_event.h
3
 *    Definitions related to wait event reporting
4
 *
5
 * Copyright (c) 2001-2026, PostgreSQL Global Development Group
6
 *
7
 * src/include/utils/wait_event.h
8
 * ----------
9
 */
10
#ifndef WAIT_EVENT_H
11
#define WAIT_EVENT_H
12
13
/* enums for wait events */
14
#include "utils/wait_event_types.h"
15
16
extern const char *pgstat_get_wait_event(uint32 wait_event_info);
17
extern const char *pgstat_get_wait_event_type(uint32 wait_event_info);
18
static inline void pgstat_report_wait_start(uint32 wait_event_info);
19
static inline void pgstat_report_wait_end(void);
20
extern void pgstat_set_wait_event_storage(uint32 *wait_event_info);
21
extern void pgstat_reset_wait_event_storage(void);
22
23
extern PGDLLIMPORT uint32 *my_wait_event_info;
24
25
26
/*
27
 * Wait Events - Extension, InjectionPoint
28
 *
29
 * Use InjectionPoint when the server process is waiting in an injection
30
 * point.  Use Extension for other cases of the server process waiting for
31
 * some condition defined by an extension module.
32
 *
33
 * Extensions can define their own wait events in these categories.  They
34
 * should call one of these functions with a wait event string.  If the wait
35
 * event associated to a string is already allocated, it returns the wait
36
 * event information to use.  If not, it gets one wait event ID allocated from
37
 * a shared counter, associates the string to the ID in the shared dynamic
38
 * hash and returns the wait event information.
39
 *
40
 * The ID retrieved can be used with pgstat_report_wait_start() or equivalent.
41
 */
42
extern uint32 WaitEventExtensionNew(const char *wait_event_name);
43
extern uint32 WaitEventInjectionPointNew(const char *wait_event_name);
44
45
extern char **GetWaitEventCustomNames(uint32 classId, int *nwaitevents);
46
47
/* ----------
48
 * pgstat_report_wait_start() -
49
 *
50
 *  Called from places where server process needs to wait.  This is called
51
 *  to report wait event information.  The wait information is stored
52
 *  as 4-bytes where first byte represents the wait event class (type of
53
 *  wait, for different types of wait, refer WaitClass) and the next
54
 *  3-bytes represent the actual wait event.  Currently 2-bytes are used
55
 *  for wait event which is sufficient for current usage, 1-byte is
56
 *  reserved for future usage.
57
 *
58
 *  Historically we used to make this reporting conditional on
59
 *  pgstat_track_activities, but the check for that seems to add more cost
60
 *  than it saves.
61
 *
62
 *  my_wait_event_info initially points to local memory, making it safe to
63
 *  call this before MyProc has been initialized.
64
 * ----------
65
 */
66
static inline void
67
pgstat_report_wait_start(uint32 wait_event_info)
68
0
{
69
  /*
70
   * Since this is a four-byte field which is always read and written as
71
   * four-bytes, updates are atomic.
72
   */
73
0
  *(volatile uint32 *) my_wait_event_info = wait_event_info;
74
0
}
Unexecuted instantiation: brin.c:pgstat_report_wait_start
Unexecuted instantiation: gininsert.c:pgstat_report_wait_start
Unexecuted instantiation: rewriteheap.c:pgstat_report_wait_start
Unexecuted instantiation: vacuumlazy.c:pgstat_report_wait_start
Unexecuted instantiation: nbtree.c:pgstat_report_wait_start
Unexecuted instantiation: nbtsort.c:pgstat_report_wait_start
Unexecuted instantiation: clog.c:pgstat_report_wait_start
Unexecuted instantiation: parallel.c:pgstat_report_wait_start
Unexecuted instantiation: slru.c:pgstat_report_wait_start
Unexecuted instantiation: timeline.c:pgstat_report_wait_start
Unexecuted instantiation: twophase.c:pgstat_report_wait_start
Unexecuted instantiation: xact.c:pgstat_report_wait_start
Unexecuted instantiation: xlog.c:pgstat_report_wait_start
Unexecuted instantiation: xlogarchive.c:pgstat_report_wait_start
Unexecuted instantiation: xlogfuncs.c:pgstat_report_wait_start
Unexecuted instantiation: xlogreader.c:pgstat_report_wait_start
Unexecuted instantiation: xlogrecovery.c:pgstat_report_wait_start
Unexecuted instantiation: xlogwait.c:pgstat_report_wait_start
Unexecuted instantiation: copyfromparse.c:pgstat_report_wait_start
Unexecuted instantiation: copyto.c:pgstat_report_wait_start
Unexecuted instantiation: dbcommands.c:pgstat_report_wait_start
Unexecuted instantiation: vacuum.c:pgstat_report_wait_start
Unexecuted instantiation: nodeAppend.c:pgstat_report_wait_start
Unexecuted instantiation: nodeBitmapHeapscan.c:pgstat_report_wait_start
Unexecuted instantiation: nodeGather.c:pgstat_report_wait_start
Unexecuted instantiation: nodeHash.c:pgstat_report_wait_start
Unexecuted instantiation: nodeHashjoin.c:pgstat_report_wait_start
Unexecuted instantiation: be-secure.c:pgstat_report_wait_start
Unexecuted instantiation: pqmq.c:pgstat_report_wait_start
Unexecuted instantiation: autovacuum.c:pgstat_report_wait_start
Unexecuted instantiation: auxprocess.c:pgstat_report_wait_start
Unexecuted instantiation: bgworker.c:pgstat_report_wait_start
Unexecuted instantiation: bgwriter.c:pgstat_report_wait_start
Unexecuted instantiation: checkpointer.c:pgstat_report_wait_start
Unexecuted instantiation: datachecksum_state.c:pgstat_report_wait_start
Unexecuted instantiation: pgarch.c:pgstat_report_wait_start
Unexecuted instantiation: syslogger.c:pgstat_report_wait_start
Unexecuted instantiation: walsummarizer.c:pgstat_report_wait_start
Unexecuted instantiation: walwriter.c:pgstat_report_wait_start
Unexecuted instantiation: applyparallelworker.c:pgstat_report_wait_start
Unexecuted instantiation: launcher.c:pgstat_report_wait_start
Unexecuted instantiation: origin.c:pgstat_report_wait_start
Unexecuted instantiation: reorderbuffer.c:pgstat_report_wait_start
Unexecuted instantiation: slotsync.c:pgstat_report_wait_start
Unexecuted instantiation: snapbuild.c:pgstat_report_wait_start
Unexecuted instantiation: tablesync.c:pgstat_report_wait_start
Unexecuted instantiation: worker.c:pgstat_report_wait_start
Unexecuted instantiation: slot.c:pgstat_report_wait_start
Unexecuted instantiation: syncrep.c:pgstat_report_wait_start
Unexecuted instantiation: walreceiver.c:pgstat_report_wait_start
Unexecuted instantiation: walreceiverfuncs.c:pgstat_report_wait_start
Unexecuted instantiation: walsender.c:pgstat_report_wait_start
Unexecuted instantiation: basebackup.c:pgstat_report_wait_start
Unexecuted instantiation: basebackup_server.c:pgstat_report_wait_start
Unexecuted instantiation: basebackup_throttle.c:pgstat_report_wait_start
Unexecuted instantiation: walsummary.c:pgstat_report_wait_start
Unexecuted instantiation: aio_io.c:pgstat_report_wait_start
Unexecuted instantiation: method_worker.c:pgstat_report_wait_start
Unexecuted instantiation: bufmgr.c:pgstat_report_wait_start
Unexecuted instantiation: buffile.c:pgstat_report_wait_start
Unexecuted instantiation: copydir.c:pgstat_report_wait_start
Unexecuted instantiation: fd.c:pgstat_report_wait_start
Unexecuted instantiation: dsm_impl.c:pgstat_report_wait_start
Unexecuted instantiation: procarray.c:pgstat_report_wait_start
Unexecuted instantiation: procsignal.c:pgstat_report_wait_start
Unexecuted instantiation: shm_mq.c:pgstat_report_wait_start
Unexecuted instantiation: signalfuncs.c:pgstat_report_wait_start
Unexecuted instantiation: standby.c:pgstat_report_wait_start
Unexecuted instantiation: waiteventset.c:pgstat_report_wait_start
Unexecuted instantiation: lwlock.c:pgstat_report_wait_start
Unexecuted instantiation: predicate.c:pgstat_report_wait_start
Unexecuted instantiation: proc.c:pgstat_report_wait_start
Unexecuted instantiation: s_lock.c:pgstat_report_wait_start
Unexecuted instantiation: md.c:pgstat_report_wait_start
Unexecuted instantiation: sync.c:pgstat_report_wait_start
Unexecuted instantiation: wait_event.c:pgstat_report_wait_start
Unexecuted instantiation: wait_event_funcs.c:pgstat_report_wait_start
Unexecuted instantiation: misc.c:pgstat_report_wait_start
Unexecuted instantiation: pgstatfuncs.c:pgstat_report_wait_start
Unexecuted instantiation: waitfuncs.c:pgstat_report_wait_start
Unexecuted instantiation: relmapper.c:pgstat_report_wait_start
Unexecuted instantiation: miscinit.c:pgstat_report_wait_start
Unexecuted instantiation: controldata_utils.c:pgstat_report_wait_start
Unexecuted instantiation: shell_archive.c:pgstat_report_wait_start
75
76
/* ----------
77
 * pgstat_report_wait_end() -
78
 *
79
 *  Called to report end of a wait.
80
 * ----------
81
 */
82
static inline void
83
pgstat_report_wait_end(void)
84
0
{
85
  /* see pgstat_report_wait_start() */
86
0
  *(volatile uint32 *) my_wait_event_info = 0;
87
0
}
Unexecuted instantiation: brin.c:pgstat_report_wait_end
Unexecuted instantiation: gininsert.c:pgstat_report_wait_end
Unexecuted instantiation: rewriteheap.c:pgstat_report_wait_end
Unexecuted instantiation: vacuumlazy.c:pgstat_report_wait_end
Unexecuted instantiation: nbtree.c:pgstat_report_wait_end
Unexecuted instantiation: nbtsort.c:pgstat_report_wait_end
Unexecuted instantiation: clog.c:pgstat_report_wait_end
Unexecuted instantiation: parallel.c:pgstat_report_wait_end
Unexecuted instantiation: slru.c:pgstat_report_wait_end
Unexecuted instantiation: timeline.c:pgstat_report_wait_end
Unexecuted instantiation: twophase.c:pgstat_report_wait_end
Unexecuted instantiation: xact.c:pgstat_report_wait_end
Unexecuted instantiation: xlog.c:pgstat_report_wait_end
Unexecuted instantiation: xlogarchive.c:pgstat_report_wait_end
Unexecuted instantiation: xlogfuncs.c:pgstat_report_wait_end
Unexecuted instantiation: xlogreader.c:pgstat_report_wait_end
Unexecuted instantiation: xlogrecovery.c:pgstat_report_wait_end
Unexecuted instantiation: xlogwait.c:pgstat_report_wait_end
Unexecuted instantiation: copyfromparse.c:pgstat_report_wait_end
Unexecuted instantiation: copyto.c:pgstat_report_wait_end
Unexecuted instantiation: dbcommands.c:pgstat_report_wait_end
Unexecuted instantiation: vacuum.c:pgstat_report_wait_end
Unexecuted instantiation: nodeAppend.c:pgstat_report_wait_end
Unexecuted instantiation: nodeBitmapHeapscan.c:pgstat_report_wait_end
Unexecuted instantiation: nodeGather.c:pgstat_report_wait_end
Unexecuted instantiation: nodeHash.c:pgstat_report_wait_end
Unexecuted instantiation: nodeHashjoin.c:pgstat_report_wait_end
Unexecuted instantiation: be-secure.c:pgstat_report_wait_end
Unexecuted instantiation: pqmq.c:pgstat_report_wait_end
Unexecuted instantiation: autovacuum.c:pgstat_report_wait_end
Unexecuted instantiation: auxprocess.c:pgstat_report_wait_end
Unexecuted instantiation: bgworker.c:pgstat_report_wait_end
Unexecuted instantiation: bgwriter.c:pgstat_report_wait_end
Unexecuted instantiation: checkpointer.c:pgstat_report_wait_end
Unexecuted instantiation: datachecksum_state.c:pgstat_report_wait_end
Unexecuted instantiation: pgarch.c:pgstat_report_wait_end
Unexecuted instantiation: syslogger.c:pgstat_report_wait_end
Unexecuted instantiation: walsummarizer.c:pgstat_report_wait_end
Unexecuted instantiation: walwriter.c:pgstat_report_wait_end
Unexecuted instantiation: applyparallelworker.c:pgstat_report_wait_end
Unexecuted instantiation: launcher.c:pgstat_report_wait_end
Unexecuted instantiation: origin.c:pgstat_report_wait_end
Unexecuted instantiation: reorderbuffer.c:pgstat_report_wait_end
Unexecuted instantiation: slotsync.c:pgstat_report_wait_end
Unexecuted instantiation: snapbuild.c:pgstat_report_wait_end
Unexecuted instantiation: tablesync.c:pgstat_report_wait_end
Unexecuted instantiation: worker.c:pgstat_report_wait_end
Unexecuted instantiation: slot.c:pgstat_report_wait_end
Unexecuted instantiation: syncrep.c:pgstat_report_wait_end
Unexecuted instantiation: walreceiver.c:pgstat_report_wait_end
Unexecuted instantiation: walreceiverfuncs.c:pgstat_report_wait_end
Unexecuted instantiation: walsender.c:pgstat_report_wait_end
Unexecuted instantiation: basebackup.c:pgstat_report_wait_end
Unexecuted instantiation: basebackup_server.c:pgstat_report_wait_end
Unexecuted instantiation: basebackup_throttle.c:pgstat_report_wait_end
Unexecuted instantiation: walsummary.c:pgstat_report_wait_end
Unexecuted instantiation: aio_io.c:pgstat_report_wait_end
Unexecuted instantiation: method_worker.c:pgstat_report_wait_end
Unexecuted instantiation: bufmgr.c:pgstat_report_wait_end
Unexecuted instantiation: buffile.c:pgstat_report_wait_end
Unexecuted instantiation: copydir.c:pgstat_report_wait_end
Unexecuted instantiation: fd.c:pgstat_report_wait_end
Unexecuted instantiation: dsm_impl.c:pgstat_report_wait_end
Unexecuted instantiation: procarray.c:pgstat_report_wait_end
Unexecuted instantiation: procsignal.c:pgstat_report_wait_end
Unexecuted instantiation: shm_mq.c:pgstat_report_wait_end
Unexecuted instantiation: signalfuncs.c:pgstat_report_wait_end
Unexecuted instantiation: standby.c:pgstat_report_wait_end
Unexecuted instantiation: waiteventset.c:pgstat_report_wait_end
Unexecuted instantiation: lwlock.c:pgstat_report_wait_end
Unexecuted instantiation: predicate.c:pgstat_report_wait_end
Unexecuted instantiation: proc.c:pgstat_report_wait_end
Unexecuted instantiation: s_lock.c:pgstat_report_wait_end
Unexecuted instantiation: md.c:pgstat_report_wait_end
Unexecuted instantiation: sync.c:pgstat_report_wait_end
Unexecuted instantiation: wait_event.c:pgstat_report_wait_end
Unexecuted instantiation: wait_event_funcs.c:pgstat_report_wait_end
Unexecuted instantiation: misc.c:pgstat_report_wait_end
Unexecuted instantiation: pgstatfuncs.c:pgstat_report_wait_end
Unexecuted instantiation: waitfuncs.c:pgstat_report_wait_end
Unexecuted instantiation: relmapper.c:pgstat_report_wait_end
Unexecuted instantiation: miscinit.c:pgstat_report_wait_end
Unexecuted instantiation: controldata_utils.c:pgstat_report_wait_end
Unexecuted instantiation: shell_archive.c:pgstat_report_wait_end
88
89
90
#endif              /* WAIT_EVENT_H */