LCOV - differential code coverage report
Current view: top level - src/backend/utils/activity - wait_event.c (source / functions) Coverage Total Hit UNC LBC UIC UBC GBC GIC GNC CBC EUB ECB DUB
Current: Differential Code Coverage HEAD vs 15 Lines: 23.0 % 575 132 23 24 14 382 17 18 97 36 11 8
Current Date: 2023-04-08 17:13:01 Functions: 88.9 % 9 8 1 3 1 4 1 3
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 [..60] days: 0.0 % 9 0 9
Legend: Lines: hit not hit (60,120] days: 0.0 % 6 0 6
(120,180] days: 0.0 % 3 0 3
(240..) days: 23.7 % 557 132 5 24 14 382 17 18 97 27 10
Function coverage date bins:
(240..) days: 61.5 % 13 8 1 3 1 4 1 3

 Age         Owner                  TLA  Line data    Source code
                                  1                 : /* ----------
                                  2                 :  * wait_event.c
                                  3                 :  *    Wait event reporting infrastructure.
                                  4                 :  *
                                  5                 :  * Copyright (c) 2001-2023, PostgreSQL Global Development Group
                                  6                 :  *
                                  7                 :  *
                                  8                 :  * IDENTIFICATION
                                  9                 :  *    src/backend/utils/activity/wait_event.c
                                 10                 :  *
                                 11                 :  * NOTES
                                 12                 :  *
                                 13                 :  * To make pgstat_report_wait_start() and pgstat_report_wait_end() as
                                 14                 :  * lightweight as possible, they do not check if shared memory (MyProc
                                 15                 :  * specifically, where the wait event is stored) is already available. Instead
                                 16                 :  * we initially set my_wait_event_info to a process local variable, which then
                                 17                 :  * is redirected to shared memory using pgstat_set_wait_event_storage(). For
                                 18                 :  * the same reason pgstat_track_activities is not checked - the check adds
                                 19                 :  * more work than it saves.
                                 20                 :  *
                                 21                 :  * ----------
                                 22                 :  */
                                 23                 : #include "postgres.h"
                                 24                 : 
                                 25                 : #include "storage/lmgr.h"     /* for GetLockNameFromTagType */
                                 26                 : #include "storage/lwlock.h"       /* for GetLWLockIdentifier */
                                 27                 : #include "utils/wait_event.h"
                                 28                 : 
                                 29                 : 
                                 30                 : static const char *pgstat_get_wait_activity(WaitEventActivity w);
                                 31                 : static const char *pgstat_get_wait_client(WaitEventClient w);
                                 32                 : static const char *pgstat_get_wait_ipc(WaitEventIPC w);
                                 33                 : static const char *pgstat_get_wait_timeout(WaitEventTimeout w);
                                 34                 : static const char *pgstat_get_wait_io(WaitEventIO w);
                                 35                 : 
                                 36                 : 
                                 37                 : static uint32 local_my_wait_event_info;
                                 38                 : uint32     *my_wait_event_info = &local_my_wait_event_info;
                                 39                 : 
                                 40                 : 
                                 41                 : /*
                                 42                 :  * Configure wait event reporting to report wait events to *wait_event_info.
                                 43                 :  * *wait_event_info needs to be valid until pgstat_reset_wait_event_storage()
                                 44                 :  * is called.
                                 45                 :  *
                                 46                 :  * Expected to be called during backend startup, to point my_wait_event_info
                                 47                 :  * into shared memory.
                                 48                 :  */
                                 49                 : void
  736 andres                     50 CBC       13303 : pgstat_set_wait_event_storage(uint32 *wait_event_info)
                                 51                 : {
                                 52           13303 :     my_wait_event_info = wait_event_info;
                                 53           13303 : }
                                 54                 : 
                                 55                 : /*
                                 56                 :  * Reset wait event storage location.
                                 57                 :  *
                                 58                 :  * Expected to be called during backend shutdown, before the location set up
                                 59                 :  * pgstat_set_wait_event_storage() becomes invalid.
                                 60                 :  */
                                 61                 : void
                                 62           13303 : pgstat_reset_wait_event_storage(void)
                                 63                 : {
                                 64           13303 :     my_wait_event_info = &local_my_wait_event_info;
                                 65           13303 : }
                                 66                 : 
                                 67                 : /* ----------
                                 68                 :  * pgstat_get_wait_event_type() -
                                 69                 :  *
                                 70                 :  *  Return a string representing the current wait event type, backend is
                                 71                 :  *  waiting on.
                                 72                 :  */
                                 73                 : const char *
  737                            74            4117 : pgstat_get_wait_event_type(uint32 wait_event_info)
                                 75                 : {
                                 76                 :     uint32      classId;
                                 77                 :     const char *event_type;
                                 78                 : 
                                 79                 :     /* report process as not waiting. */
                                 80            4117 :     if (wait_event_info == 0)
                                 81             618 :         return NULL;
                                 82                 : 
                                 83            3499 :     classId = wait_event_info & 0xFF000000;
                                 84                 : 
                                 85            3499 :     switch (classId)
                                 86                 :     {
  737 andres                     87 UBC           0 :         case PG_WAIT_LWLOCK:
                                 88               0 :             event_type = "LWLock";
                                 89               0 :             break;
  737 andres                     90 CBC           7 :         case PG_WAIT_LOCK:
                                 91               7 :             event_type = "Lock";
                                 92               7 :             break;
  737 andres                     93 UBC           0 :         case PG_WAIT_BUFFER_PIN:
                                 94               0 :             event_type = "BufferPin";
                                 95               0 :             break;
  737 andres                     96 CBC        3000 :         case PG_WAIT_ACTIVITY:
                                 97            3000 :             event_type = "Activity";
                                 98            3000 :             break;
                                 99             480 :         case PG_WAIT_CLIENT:
                                100             480 :             event_type = "Client";
                                101             480 :             break;
                                102               4 :         case PG_WAIT_EXTENSION:
                                103               4 :             event_type = "Extension";
                                104               4 :             break;
  737 andres                    105 UBC           0 :         case PG_WAIT_IPC:
                                106               0 :             event_type = "IPC";
                                107               0 :             break;
  737 andres                    108 CBC           7 :         case PG_WAIT_TIMEOUT:
                                109               7 :             event_type = "Timeout";
                                110               7 :             break;
                                111               1 :         case PG_WAIT_IO:
                                112               1 :             event_type = "IO";
                                113               1 :             break;
  737 andres                    114 UBC           0 :         default:
                                115               0 :             event_type = "???";
                                116               0 :             break;
                                117                 :     }
                                118                 : 
  737 andres                    119 CBC        3499 :     return event_type;
                                120                 : }
                                121                 : 
                                122                 : /* ----------
                                123                 :  * pgstat_get_wait_event() -
                                124                 :  *
                                125                 :  *  Return a string representing the current wait event, backend is
                                126                 :  *  waiting on.
                                127                 :  */
                                128                 : const char *
                                129            4117 : pgstat_get_wait_event(uint32 wait_event_info)
                                130                 : {
                                131                 :     uint32      classId;
                                132                 :     uint16      eventId;
                                133                 :     const char *event_name;
                                134                 : 
                                135                 :     /* report process as not waiting. */
                                136            4117 :     if (wait_event_info == 0)
                                137             618 :         return NULL;
                                138                 : 
                                139            3499 :     classId = wait_event_info & 0xFF000000;
                                140            3499 :     eventId = wait_event_info & 0x0000FFFF;
                                141                 : 
                                142            3499 :     switch (classId)
                                143                 :     {
  737 andres                    144 UBC           0 :         case PG_WAIT_LWLOCK:
                                145               0 :             event_name = GetLWLockIdentifier(classId, eventId);
                                146               0 :             break;
  737 andres                    147 CBC           7 :         case PG_WAIT_LOCK:
                                148               7 :             event_name = GetLockNameFromTagType(eventId);
                                149               7 :             break;
  737 andres                    150 UBC           0 :         case PG_WAIT_BUFFER_PIN:
                                151               0 :             event_name = "BufferPin";
                                152               0 :             break;
  737 andres                    153 CBC        3000 :         case PG_WAIT_ACTIVITY:
                                154                 :             {
                                155            3000 :                 WaitEventActivity w = (WaitEventActivity) wait_event_info;
                                156                 : 
                                157            3000 :                 event_name = pgstat_get_wait_activity(w);
                                158            3000 :                 break;
                                159                 :             }
                                160             480 :         case PG_WAIT_CLIENT:
                                161                 :             {
                                162             480 :                 WaitEventClient w = (WaitEventClient) wait_event_info;
                                163                 : 
                                164             480 :                 event_name = pgstat_get_wait_client(w);
                                165             480 :                 break;
                                166                 :             }
                                167               4 :         case PG_WAIT_EXTENSION:
                                168               4 :             event_name = "Extension";
                                169               4 :             break;
  737 andres                    170 UBC           0 :         case PG_WAIT_IPC:
                                171                 :             {
                                172               0 :                 WaitEventIPC w = (WaitEventIPC) wait_event_info;
                                173                 : 
                                174               0 :                 event_name = pgstat_get_wait_ipc(w);
                                175               0 :                 break;
                                176                 :             }
  737 andres                    177 CBC           7 :         case PG_WAIT_TIMEOUT:
                                178                 :             {
                                179               7 :                 WaitEventTimeout w = (WaitEventTimeout) wait_event_info;
                                180                 : 
                                181               7 :                 event_name = pgstat_get_wait_timeout(w);
                                182               7 :                 break;
                                183                 :             }
                                184               1 :         case PG_WAIT_IO:
                                185                 :             {
                                186               1 :                 WaitEventIO w = (WaitEventIO) wait_event_info;
                                187                 : 
                                188               1 :                 event_name = pgstat_get_wait_io(w);
                                189               1 :                 break;
                                190                 :             }
  737 andres                    191 UBC           0 :         default:
                                192               0 :             event_name = "unknown wait event";
                                193               0 :             break;
                                194                 :     }
                                195                 : 
  737 andres                    196 CBC        3499 :     return event_name;
                                197                 : }
                                198                 : 
                                199                 : /* ----------
                                200                 :  * pgstat_get_wait_activity() -
                                201                 :  *
                                202                 :  * Convert WaitEventActivity to string.
                                203                 :  * ----------
                                204                 :  */
                                205                 : static const char *
                                206            3000 : pgstat_get_wait_activity(WaitEventActivity w)
                                207                 : {
                                208            3000 :     const char *event_name = "unknown wait event";
                                209                 : 
                                210            3000 :     switch (w)
                                211                 :     {
                                212              19 :         case WAIT_EVENT_ARCHIVER_MAIN:
                                213              19 :             event_name = "ArchiverMain";
                                214              19 :             break;
                                215             544 :         case WAIT_EVENT_AUTOVACUUM_MAIN:
                                216             544 :             event_name = "AutoVacuumMain";
                                217             544 :             break;
                                218              19 :         case WAIT_EVENT_BGWRITER_HIBERNATE:
                                219              19 :             event_name = "BgWriterHibernate";
                                220              19 :             break;
                                221             538 :         case WAIT_EVENT_BGWRITER_MAIN:
                                222             538 :             event_name = "BgWriterMain";
                                223             538 :             break;
                                224             553 :         case WAIT_EVENT_CHECKPOINTER_MAIN:
                                225             553 :             event_name = "CheckpointerMain";
                                226             553 :             break;
                                227              33 :         case WAIT_EVENT_LOGICAL_APPLY_MAIN:
                                228              33 :             event_name = "LogicalApplyMain";
                                229              33 :             break;
                                230             547 :         case WAIT_EVENT_LOGICAL_LAUNCHER_MAIN:
                                231             547 :             event_name = "LogicalLauncherMain";
                                232             547 :             break;
   90 akapila                   233 UNC           0 :         case WAIT_EVENT_LOGICAL_PARALLEL_APPLY_MAIN:
                                234               0 :             event_name = "LogicalParallelApplyMain";
                                235               0 :             break;
  737 andres                    236 GBC          10 :         case WAIT_EVENT_RECOVERY_WAL_STREAM:
                                237              10 :             event_name = "RecoveryWalStream";
                                238              10 :             break;
  737 andres                    239 LBC           0 :         case WAIT_EVENT_SYSLOGGER_MAIN:
                                240               0 :             event_name = "SysLoggerMain";
                                241               0 :             break;
  737 andres                    242 GBC          10 :         case WAIT_EVENT_WAL_RECEIVER_MAIN:
                                243              10 :             event_name = "WalReceiverMain";
                                244              10 :             break;
  737 andres                    245 CBC         180 :         case WAIT_EVENT_WAL_SENDER_MAIN:
                                246             180 :             event_name = "WalSenderMain";
                                247             180 :             break;
                                248             547 :         case WAIT_EVENT_WAL_WRITER_MAIN:
                                249             547 :             event_name = "WalWriterMain";
                                250             547 :             break;
  737 andres                    251 ECB             :             /* no default case, so that compiler will warn */
                                252                 :     }
                                253                 : 
  737 andres                    254 GIC        3000 :     return event_name;
                                255                 : }
                                256                 : 
  737 andres                    257 ECB             : /* ----------
                                258                 :  * pgstat_get_wait_client() -
                                259                 :  *
                                260                 :  * Convert WaitEventClient to string.
                                261                 :  * ----------
                                262                 :  */
                                263                 : static const char *
  737 andres                    264 GIC         480 : pgstat_get_wait_client(WaitEventClient w)
                                265                 : {
                                266             480 :     const char *event_name = "unknown wait event";
  737 andres                    267 ECB             : 
  737 andres                    268 GIC         480 :     switch (w)
  737 andres                    269 ECB             :     {
  737 andres                    270 GIC          31 :         case WAIT_EVENT_CLIENT_READ:
  737 andres                    271 CBC          31 :             event_name = "ClientRead";
  737 andres                    272 GIC          31 :             break;
  737 andres                    273 LBC           0 :         case WAIT_EVENT_CLIENT_WRITE:
                                274               0 :             event_name = "ClientWrite";
                                275               0 :             break;
  737 andres                    276 UBC           0 :         case WAIT_EVENT_GSS_OPEN_SERVER:
                                277               0 :             event_name = "GSSOpenServer";
                                278               0 :             break;
                                279               0 :         case WAIT_EVENT_LIBPQWALRECEIVER_CONNECT:
                                280               0 :             event_name = "LibPQWalReceiverConnect";
                                281               0 :             break;
  737 andres                    282 GBC           1 :         case WAIT_EVENT_LIBPQWALRECEIVER_RECEIVE:
                                283               1 :             event_name = "LibPQWalReceiverReceive";
                                284               1 :             break;
  737 andres                    285 LBC           0 :         case WAIT_EVENT_SSL_OPEN_SERVER:
                                286               0 :             event_name = "SSLOpenServer";
                                287               0 :             break;
  737 andres                    288 GBC         447 :         case WAIT_EVENT_WAL_SENDER_WAIT_WAL:
                                289             447 :             event_name = "WalSenderWaitForWAL";
                                290             447 :             break;
  737 andres                    291 CBC           1 :         case WAIT_EVENT_WAL_SENDER_WRITE_DATA:
                                292               1 :             event_name = "WalSenderWriteData";
                                293               1 :             break;
  737 andres                    294 ECB             :             /* no default case, so that compiler will warn */
                                295                 :     }
                                296                 : 
  737 andres                    297 GIC         480 :     return event_name;
                                298                 : }
                                299                 : 
  737 andres                    300 ECB             : /* ----------
                                301                 :  * pgstat_get_wait_ipc() -
                                302                 :  *
                                303                 :  * Convert WaitEventIPC to string.
                                304                 :  * ----------
                                305                 :  */
                                306                 : static const char *
  737 andres                    307 UIC           0 : pgstat_get_wait_ipc(WaitEventIPC w)
                                308                 : {
                                309               0 :     const char *event_name = "unknown wait event";
  737 andres                    310 EUB             : 
  737 andres                    311 UIC           0 :     switch (w)
  737 andres                    312 EUB             :     {
  737 andres                    313 UIC           0 :         case WAIT_EVENT_APPEND_READY:
  737 andres                    314 UBC           0 :             event_name = "AppendReady";
  737 andres                    315 UIC           0 :             break;
  503 fujii                     316 UBC           0 :         case WAIT_EVENT_ARCHIVE_CLEANUP_COMMAND:
                                317               0 :             event_name = "ArchiveCleanupCommand";
                                318               0 :             break;
                                319               0 :         case WAIT_EVENT_ARCHIVE_COMMAND:
                                320               0 :             event_name = "ArchiveCommand";
                                321               0 :             break;
  731 magnus                    322               0 :         case WAIT_EVENT_BACKEND_TERMINATION:
                                323               0 :             event_name = "BackendTermination";
                                324               0 :             break;
  737 andres                    325               0 :         case WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE:
                                326               0 :             event_name = "BackupWaitWalArchive";
                                327               0 :             break;
                                328               0 :         case WAIT_EVENT_BGWORKER_SHUTDOWN:
                                329               0 :             event_name = "BgWorkerShutdown";
                                330               0 :             break;
                                331               0 :         case WAIT_EVENT_BGWORKER_STARTUP:
                                332               0 :             event_name = "BgWorkerStartup";
                                333               0 :             break;
                                334               0 :         case WAIT_EVENT_BTREE_PAGE:
                                335               0 :             event_name = "BtreePage";
                                336               0 :             break;
                                337               0 :         case WAIT_EVENT_BUFFER_IO:
                                338               0 :             event_name = "BufferIO";
                                339               0 :             break;
                                340               0 :         case WAIT_EVENT_CHECKPOINT_DONE:
                                341               0 :             event_name = "CheckpointDone";
                                342               0 :             break;
                                343               0 :         case WAIT_EVENT_CHECKPOINT_START:
                                344               0 :             event_name = "CheckpointStart";
                                345               0 :             break;
                                346               0 :         case WAIT_EVENT_EXECUTE_GATHER:
                                347               0 :             event_name = "ExecuteGather";
                                348               0 :             break;
                                349               0 :         case WAIT_EVENT_HASH_BATCH_ALLOCATE:
                                350               0 :             event_name = "HashBatchAllocate";
                                351               0 :             break;
                                352               0 :         case WAIT_EVENT_HASH_BATCH_ELECT:
                                353               0 :             event_name = "HashBatchElect";
                                354               0 :             break;
                                355               0 :         case WAIT_EVENT_HASH_BATCH_LOAD:
                                356               0 :             event_name = "HashBatchLoad";
                                357               0 :             break;
                                358               0 :         case WAIT_EVENT_HASH_BUILD_ALLOCATE:
                                359               0 :             event_name = "HashBuildAllocate";
                                360               0 :             break;
                                361               0 :         case WAIT_EVENT_HASH_BUILD_ELECT:
                                362               0 :             event_name = "HashBuildElect";
                                363               0 :             break;
                                364               0 :         case WAIT_EVENT_HASH_BUILD_HASH_INNER:
                                365               0 :             event_name = "HashBuildHashInner";
                                366               0 :             break;
                                367               0 :         case WAIT_EVENT_HASH_BUILD_HASH_OUTER:
                                368               0 :             event_name = "HashBuildHashOuter";
                                369               0 :             break;
                                370               0 :         case WAIT_EVENT_HASH_GROW_BATCHES_DECIDE:
                                371               0 :             event_name = "HashGrowBatchesDecide";
                                372               0 :             break;
                                373               0 :         case WAIT_EVENT_HASH_GROW_BATCHES_ELECT:
                                374               0 :             event_name = "HashGrowBatchesElect";
                                375               0 :             break;
                                376               0 :         case WAIT_EVENT_HASH_GROW_BATCHES_FINISH:
                                377               0 :             event_name = "HashGrowBatchesFinish";
                                378               0 :             break;
   17 tmunro                    379 UNC           0 :         case WAIT_EVENT_HASH_GROW_BATCHES_REALLOCATE:
                                380               0 :             event_name = "HashGrowBatchesReallocate";
                                381               0 :             break;
  737 andres                    382 UBC           0 :         case WAIT_EVENT_HASH_GROW_BATCHES_REPARTITION:
                                383               0 :             event_name = "HashGrowBatchesRepartition";
                                384               0 :             break;
                                385               0 :         case WAIT_EVENT_HASH_GROW_BUCKETS_ELECT:
                                386               0 :             event_name = "HashGrowBucketsElect";
                                387               0 :             break;
   17 tmunro                    388 UNC           0 :         case WAIT_EVENT_HASH_GROW_BUCKETS_REALLOCATE:
                                389               0 :             event_name = "HashGrowBucketsReallocate";
                                390               0 :             break;
  737 andres                    391 UBC           0 :         case WAIT_EVENT_HASH_GROW_BUCKETS_REINSERT:
                                392               0 :             event_name = "HashGrowBucketsReinsert";
                                393               0 :             break;
   52 akapila                   394 UNC           0 :         case WAIT_EVENT_LOGICAL_APPLY_SEND_DATA:
                                395               0 :             event_name = "LogicalApplySendData";
                                396               0 :             break;
   90                           397               0 :         case WAIT_EVENT_LOGICAL_PARALLEL_APPLY_STATE_CHANGE:
                                398               0 :             event_name = "LogicalParallelApplyStateChange";
                                399               0 :             break;
  737 andres                    400 UBC           0 :         case WAIT_EVENT_LOGICAL_SYNC_DATA:
                                401               0 :             event_name = "LogicalSyncData";
                                402               0 :             break;
                                403               0 :         case WAIT_EVENT_LOGICAL_SYNC_STATE_CHANGE:
                                404               0 :             event_name = "LogicalSyncStateChange";
                                405               0 :             break;
                                406               0 :         case WAIT_EVENT_MQ_INTERNAL:
                                407               0 :             event_name = "MessageQueueInternal";
                                408               0 :             break;
                                409               0 :         case WAIT_EVENT_MQ_PUT_MESSAGE:
                                410               0 :             event_name = "MessageQueuePutMessage";
                                411               0 :             break;
                                412               0 :         case WAIT_EVENT_MQ_RECEIVE:
                                413               0 :             event_name = "MessageQueueReceive";
                                414               0 :             break;
                                415               0 :         case WAIT_EVENT_MQ_SEND:
                                416               0 :             event_name = "MessageQueueSend";
                                417               0 :             break;
                                418               0 :         case WAIT_EVENT_PARALLEL_BITMAP_SCAN:
                                419               0 :             event_name = "ParallelBitmapScan";
                                420               0 :             break;
                                421               0 :         case WAIT_EVENT_PARALLEL_CREATE_INDEX_SCAN:
                                422               0 :             event_name = "ParallelCreateIndexScan";
                                423               0 :             break;
                                424               0 :         case WAIT_EVENT_PARALLEL_FINISH:
                                425               0 :             event_name = "ParallelFinish";
                                426               0 :             break;
                                427               0 :         case WAIT_EVENT_PROCARRAY_GROUP_UPDATE:
                                428               0 :             event_name = "ProcArrayGroupUpdate";
                                429               0 :             break;
                                430               0 :         case WAIT_EVENT_PROC_SIGNAL_BARRIER:
                                431               0 :             event_name = "ProcSignalBarrier";
                                432               0 :             break;
                                433               0 :         case WAIT_EVENT_PROMOTE:
                                434               0 :             event_name = "Promote";
                                435               0 :             break;
                                436               0 :         case WAIT_EVENT_RECOVERY_CONFLICT_SNAPSHOT:
                                437               0 :             event_name = "RecoveryConflictSnapshot";
                                438               0 :             break;
                                439               0 :         case WAIT_EVENT_RECOVERY_CONFLICT_TABLESPACE:
                                440               0 :             event_name = "RecoveryConflictTablespace";
                                441               0 :             break;
  503 fujii                     442               0 :         case WAIT_EVENT_RECOVERY_END_COMMAND:
                                443               0 :             event_name = "RecoveryEndCommand";
                                444               0 :             break;
  737 andres                    445               0 :         case WAIT_EVENT_RECOVERY_PAUSE:
                                446               0 :             event_name = "RecoveryPause";
                                447               0 :             break;
                                448               0 :         case WAIT_EVENT_REPLICATION_ORIGIN_DROP:
                                449               0 :             event_name = "ReplicationOriginDrop";
                                450               0 :             break;
                                451               0 :         case WAIT_EVENT_REPLICATION_SLOT_DROP:
                                452               0 :             event_name = "ReplicationSlotDrop";
                                453               0 :             break;
  503 fujii                     454               0 :         case WAIT_EVENT_RESTORE_COMMAND:
                                455               0 :             event_name = "RestoreCommand";
                                456               0 :             break;
  737 andres                    457               0 :         case WAIT_EVENT_SAFE_SNAPSHOT:
                                458               0 :             event_name = "SafeSnapshot";
                                459               0 :             break;
                                460               0 :         case WAIT_EVENT_SYNC_REP:
                                461               0 :             event_name = "SyncRep";
                                462               0 :             break;
                                463               0 :         case WAIT_EVENT_WAL_RECEIVER_EXIT:
                                464               0 :             event_name = "WalReceiverExit";
                                465               0 :             break;
                                466               0 :         case WAIT_EVENT_WAL_RECEIVER_WAIT_START:
                                467               0 :             event_name = "WalReceiverWaitStart";
                                468               0 :             break;
                                469               0 :         case WAIT_EVENT_XACT_GROUP_UPDATE:
                                470               0 :             event_name = "XactGroupUpdate";
                                471               0 :             break;
  737 andres                    472 EUB             :             /* no default case, so that compiler will warn */
                                473                 :     }
                                474                 : 
  737 andres                    475 UBC           0 :     return event_name;
  737 andres                    476 EUB             : }
                                477                 : 
                                478                 : /* ----------
                                479                 :  * pgstat_get_wait_timeout() -
                                480                 :  *
                                481                 :  * Convert WaitEventTimeout to string.
                                482                 :  * ----------
                                483                 :  */
                                484                 : static const char *
  737 andres                    485 GIC           7 : pgstat_get_wait_timeout(WaitEventTimeout w)
                                486                 : {
                                487               7 :     const char *event_name = "unknown wait event";
                                488                 : 
                                489               7 :     switch (w)
                                490                 :     {
                                491               2 :         case WAIT_EVENT_BASE_BACKUP_THROTTLE:
                                492               2 :             event_name = "BaseBackupThrottle";
                                493               2 :             break;
  389 tmunro                    494 CBC           4 :         case WAIT_EVENT_CHECKPOINT_WRITE_DELAY:
  389 tmunro                    495 GIC           4 :             event_name = "CheckpointWriteDelay";
  389 tmunro                    496 CBC           4 :             break;
  737 andres                    497 GIC           1 :         case WAIT_EVENT_PG_SLEEP:
  737 andres                    498 CBC           1 :             event_name = "PgSleep";
  737 andres                    499 GIC           1 :             break;
  737 andres                    500 LBC           0 :         case WAIT_EVENT_RECOVERY_APPLY_DELAY:
                                501               0 :             event_name = "RecoveryApplyDelay";
                                502               0 :             break;
                                503               0 :         case WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL:
                                504               0 :             event_name = "RecoveryRetrieveRetryInterval";
                                505               0 :             break;
  389 tmunro                    506               0 :         case WAIT_EVENT_REGISTER_SYNC_REQUEST:
                                507               0 :             event_name = "RegisterSyncRequest";
                                508               0 :             break;
  139 andres                    509 UNC           0 :         case WAIT_EVENT_SPIN_DELAY:
                                510               0 :             event_name = "SpinDelay";
                                511               0 :             break;
  737 andres                    512 UBC           0 :         case WAIT_EVENT_VACUUM_DELAY:
                                513               0 :             event_name = "VacuumDelay";
                                514               0 :             break;
  646 michael                   515               0 :         case WAIT_EVENT_VACUUM_TRUNCATE:
                                516               0 :             event_name = "VacuumTruncate";
                                517               0 :             break;
  737 andres                    518 EUB             :             /* no default case, so that compiler will warn */
                                519                 :     }
                                520                 : 
  737 andres                    521 GBC           7 :     return event_name;
  737 andres                    522 EUB             : }
                                523                 : 
                                524                 : /* ----------
                                525                 :  * pgstat_get_wait_io() -
                                526                 :  *
                                527                 :  * Convert WaitEventIO to string.
                                528                 :  * ----------
                                529                 :  */
                                530                 : static const char *
  737 andres                    531 GIC           1 : pgstat_get_wait_io(WaitEventIO w)
                                532                 : {
  737 andres                    533 CBC           1 :     const char *event_name = "unknown wait event";
                                534                 : 
  737 andres                    535 GIC           1 :     switch (w)
                                536                 :     {
  737 andres                    537 UIC           0 :         case WAIT_EVENT_BASEBACKUP_READ:
                                538               0 :             event_name = "BaseBackupRead";
                                539               0 :             break;
  509 rhaas                     540               0 :         case WAIT_EVENT_BASEBACKUP_SYNC:
                                541               0 :             event_name = "BaseBackupSync";
                                542               0 :             break;
  509 rhaas                     543 LBC           0 :         case WAIT_EVENT_BASEBACKUP_WRITE:
  509 rhaas                     544 UIC           0 :             event_name = "BaseBackupWrite";
  509 rhaas                     545 LBC           0 :             break;
  737 andres                    546 UIC           0 :         case WAIT_EVENT_BUFFILE_READ:
  737 andres                    547 LBC           0 :             event_name = "BufFileRead";
  737 andres                    548 UIC           0 :             break;
  737 andres                    549 UBC           0 :         case WAIT_EVENT_BUFFILE_WRITE:
                                550               0 :             event_name = "BufFileWrite";
                                551               0 :             break;
                                552               0 :         case WAIT_EVENT_BUFFILE_TRUNCATE:
                                553               0 :             event_name = "BufFileTruncate";
                                554               0 :             break;
                                555               0 :         case WAIT_EVENT_CONTROL_FILE_READ:
                                556               0 :             event_name = "ControlFileRead";
                                557               0 :             break;
                                558               0 :         case WAIT_EVENT_CONTROL_FILE_SYNC:
                                559               0 :             event_name = "ControlFileSync";
                                560               0 :             break;
                                561               0 :         case WAIT_EVENT_CONTROL_FILE_SYNC_UPDATE:
                                562               0 :             event_name = "ControlFileSyncUpdate";
                                563               0 :             break;
                                564               0 :         case WAIT_EVENT_CONTROL_FILE_WRITE:
                                565               0 :             event_name = "ControlFileWrite";
                                566               0 :             break;
                                567               0 :         case WAIT_EVENT_CONTROL_FILE_WRITE_UPDATE:
                                568               0 :             event_name = "ControlFileWriteUpdate";
                                569               0 :             break;
                                570               0 :         case WAIT_EVENT_COPY_FILE_READ:
                                571               0 :             event_name = "CopyFileRead";
                                572               0 :             break;
                                573               0 :         case WAIT_EVENT_COPY_FILE_WRITE:
                                574               0 :             event_name = "CopyFileWrite";
                                575               0 :             break;
                                576               0 :         case WAIT_EVENT_DATA_FILE_EXTEND:
                                577               0 :             event_name = "DataFileExtend";
                                578               0 :             break;
                                579               0 :         case WAIT_EVENT_DATA_FILE_FLUSH:
                                580               0 :             event_name = "DataFileFlush";
                                581               0 :             break;
                                582               0 :         case WAIT_EVENT_DATA_FILE_IMMEDIATE_SYNC:
                                583               0 :             event_name = "DataFileImmediateSync";
                                584               0 :             break;
                                585               0 :         case WAIT_EVENT_DATA_FILE_PREFETCH:
                                586               0 :             event_name = "DataFilePrefetch";
                                587               0 :             break;
                                588               0 :         case WAIT_EVENT_DATA_FILE_READ:
                                589               0 :             event_name = "DataFileRead";
                                590               0 :             break;
                                591               0 :         case WAIT_EVENT_DATA_FILE_SYNC:
                                592               0 :             event_name = "DataFileSync";
                                593               0 :             break;
                                594               0 :         case WAIT_EVENT_DATA_FILE_TRUNCATE:
                                595               0 :             event_name = "DataFileTruncate";
                                596               0 :             break;
                                597               0 :         case WAIT_EVENT_DATA_FILE_WRITE:
                                598               0 :             event_name = "DataFileWrite";
                                599               0 :             break;
  269 tmunro                    600 UNC           0 :         case WAIT_EVENT_DSM_ALLOCATE:
                                601               0 :             event_name = "DSMAllocate";
                                602               0 :             break;
  737 andres                    603 UBC           0 :         case WAIT_EVENT_DSM_FILL_ZERO_WRITE:
                                604               0 :             event_name = "DSMFillZeroWrite";
                                605               0 :             break;
                                606               0 :         case WAIT_EVENT_LOCK_FILE_ADDTODATADIR_READ:
                                607               0 :             event_name = "LockFileAddToDataDirRead";
                                608               0 :             break;
                                609               0 :         case WAIT_EVENT_LOCK_FILE_ADDTODATADIR_SYNC:
                                610               0 :             event_name = "LockFileAddToDataDirSync";
                                611               0 :             break;
                                612               0 :         case WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE:
                                613               0 :             event_name = "LockFileAddToDataDirWrite";
                                614               0 :             break;
                                615               0 :         case WAIT_EVENT_LOCK_FILE_CREATE_READ:
                                616               0 :             event_name = "LockFileCreateRead";
                                617               0 :             break;
                                618               0 :         case WAIT_EVENT_LOCK_FILE_CREATE_SYNC:
                                619               0 :             event_name = "LockFileCreateSync";
                                620               0 :             break;
                                621               0 :         case WAIT_EVENT_LOCK_FILE_CREATE_WRITE:
                                622               0 :             event_name = "LockFileCreateWrite";
                                623               0 :             break;
                                624               0 :         case WAIT_EVENT_LOCK_FILE_RECHECKDATADIR_READ:
                                625               0 :             event_name = "LockFileReCheckDataDirRead";
                                626               0 :             break;
                                627               0 :         case WAIT_EVENT_LOGICAL_REWRITE_CHECKPOINT_SYNC:
                                628               0 :             event_name = "LogicalRewriteCheckpointSync";
                                629               0 :             break;
                                630               0 :         case WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC:
                                631               0 :             event_name = "LogicalRewriteMappingSync";
                                632               0 :             break;
                                633               0 :         case WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE:
                                634               0 :             event_name = "LogicalRewriteMappingWrite";
                                635               0 :             break;
                                636               0 :         case WAIT_EVENT_LOGICAL_REWRITE_SYNC:
                                637               0 :             event_name = "LogicalRewriteSync";
                                638               0 :             break;
                                639               0 :         case WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE:
                                640               0 :             event_name = "LogicalRewriteTruncate";
                                641               0 :             break;
                                642               0 :         case WAIT_EVENT_LOGICAL_REWRITE_WRITE:
                                643               0 :             event_name = "LogicalRewriteWrite";
                                644               0 :             break;
                                645               0 :         case WAIT_EVENT_RELATION_MAP_READ:
                                646               0 :             event_name = "RelationMapRead";
                                647               0 :             break;
  257 rhaas                     648 UNC           0 :         case WAIT_EVENT_RELATION_MAP_REPLACE:
                                649               0 :             event_name = "RelationMapReplace";
  737 andres                    650 UBC           0 :             break;
                                651               0 :         case WAIT_EVENT_RELATION_MAP_WRITE:
                                652               0 :             event_name = "RelationMapWrite";
                                653               0 :             break;
                                654               0 :         case WAIT_EVENT_REORDER_BUFFER_READ:
                                655               0 :             event_name = "ReorderBufferRead";
                                656               0 :             break;
  737 andres                    657 GBC           1 :         case WAIT_EVENT_REORDER_BUFFER_WRITE:
                                658               1 :             event_name = "ReorderBufferWrite";
                                659               1 :             break;
  737 andres                    660 UBC           0 :         case WAIT_EVENT_REORDER_LOGICAL_MAPPING_READ:
                                661               0 :             event_name = "ReorderLogicalMappingRead";
                                662               0 :             break;
                                663               0 :         case WAIT_EVENT_REPLICATION_SLOT_READ:
                                664               0 :             event_name = "ReplicationSlotRead";
                                665               0 :             break;
                                666               0 :         case WAIT_EVENT_REPLICATION_SLOT_RESTORE_SYNC:
                                667               0 :             event_name = "ReplicationSlotRestoreSync";
                                668               0 :             break;
                                669               0 :         case WAIT_EVENT_REPLICATION_SLOT_SYNC:
                                670               0 :             event_name = "ReplicationSlotSync";
                                671               0 :             break;
  737 andres                    672 LBC           0 :         case WAIT_EVENT_REPLICATION_SLOT_WRITE:
                                673               0 :             event_name = "ReplicationSlotWrite";
                                674               0 :             break;
  737 andres                    675 UBC           0 :         case WAIT_EVENT_SLRU_FLUSH_SYNC:
                                676               0 :             event_name = "SLRUFlushSync";
                                677               0 :             break;
                                678               0 :         case WAIT_EVENT_SLRU_READ:
                                679               0 :             event_name = "SLRURead";
                                680               0 :             break;
                                681               0 :         case WAIT_EVENT_SLRU_SYNC:
                                682               0 :             event_name = "SLRUSync";
                                683               0 :             break;
                                684               0 :         case WAIT_EVENT_SLRU_WRITE:
                                685               0 :             event_name = "SLRUWrite";
                                686               0 :             break;
                                687               0 :         case WAIT_EVENT_SNAPBUILD_READ:
                                688               0 :             event_name = "SnapbuildRead";
                                689               0 :             break;
                                690               0 :         case WAIT_EVENT_SNAPBUILD_SYNC:
                                691               0 :             event_name = "SnapbuildSync";
                                692               0 :             break;
                                693               0 :         case WAIT_EVENT_SNAPBUILD_WRITE:
                                694               0 :             event_name = "SnapbuildWrite";
                                695               0 :             break;
                                696               0 :         case WAIT_EVENT_TIMELINE_HISTORY_FILE_SYNC:
                                697               0 :             event_name = "TimelineHistoryFileSync";
                                698               0 :             break;
                                699               0 :         case WAIT_EVENT_TIMELINE_HISTORY_FILE_WRITE:
                                700               0 :             event_name = "TimelineHistoryFileWrite";
                                701               0 :             break;
                                702               0 :         case WAIT_EVENT_TIMELINE_HISTORY_READ:
                                703               0 :             event_name = "TimelineHistoryRead";
                                704               0 :             break;
                                705               0 :         case WAIT_EVENT_TIMELINE_HISTORY_SYNC:
                                706               0 :             event_name = "TimelineHistorySync";
                                707               0 :             break;
                                708               0 :         case WAIT_EVENT_TIMELINE_HISTORY_WRITE:
                                709               0 :             event_name = "TimelineHistoryWrite";
                                710               0 :             break;
                                711               0 :         case WAIT_EVENT_TWOPHASE_FILE_READ:
                                712               0 :             event_name = "TwophaseFileRead";
                                713               0 :             break;
                                714               0 :         case WAIT_EVENT_TWOPHASE_FILE_SYNC:
                                715               0 :             event_name = "TwophaseFileSync";
                                716               0 :             break;
                                717               0 :         case WAIT_EVENT_TWOPHASE_FILE_WRITE:
                                718               0 :             event_name = "TwophaseFileWrite";
                                719               0 :             break;
  376 rhaas                     720               0 :         case WAIT_EVENT_VERSION_FILE_WRITE:
                                721               0 :             event_name = "VersionFileWrite";
                                722               0 :             break;
  737 andres                    723               0 :         case WAIT_EVENT_WALSENDER_TIMELINE_HISTORY_READ:
                                724               0 :             event_name = "WALSenderTimelineHistoryRead";
                                725               0 :             break;
                                726               0 :         case WAIT_EVENT_WAL_BOOTSTRAP_SYNC:
                                727               0 :             event_name = "WALBootstrapSync";
                                728               0 :             break;
                                729               0 :         case WAIT_EVENT_WAL_BOOTSTRAP_WRITE:
                                730               0 :             event_name = "WALBootstrapWrite";
                                731               0 :             break;
                                732               0 :         case WAIT_EVENT_WAL_COPY_READ:
                                733               0 :             event_name = "WALCopyRead";
                                734               0 :             break;
                                735               0 :         case WAIT_EVENT_WAL_COPY_SYNC:
                                736               0 :             event_name = "WALCopySync";
                                737               0 :             break;
                                738               0 :         case WAIT_EVENT_WAL_COPY_WRITE:
                                739               0 :             event_name = "WALCopyWrite";
                                740               0 :             break;
                                741               0 :         case WAIT_EVENT_WAL_INIT_SYNC:
                                742               0 :             event_name = "WALInitSync";
                                743               0 :             break;
                                744               0 :         case WAIT_EVENT_WAL_INIT_WRITE:
                                745               0 :             event_name = "WALInitWrite";
                                746               0 :             break;
                                747               0 :         case WAIT_EVENT_WAL_READ:
                                748               0 :             event_name = "WALRead";
                                749               0 :             break;
                                750               0 :         case WAIT_EVENT_WAL_SYNC:
                                751               0 :             event_name = "WALSync";
                                752               0 :             break;
                                753               0 :         case WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN:
                                754               0 :             event_name = "WALSyncMethodAssign";
                                755               0 :             break;
                                756               0 :         case WAIT_EVENT_WAL_WRITE:
                                757               0 :             event_name = "WALWrite";
                                758               0 :             break;
  737 andres                    759 EUB             : 
                                760                 :             /* no default case, so that compiler will warn */
                                761                 :     }
                                762                 : 
  737 andres                    763 GBC           1 :     return event_name;
  737 andres                    764 EUB             : }
        

Generated by: LCOV version v1.16-55-g56c0a2a