@@ -37,7 +37,7 @@ static void handle_sigterm(SIGNAL_ARGS);
37
37
* Register background worker for collecting waits history.
38
38
*/
39
39
void
40
- register_wait_collector (void )
40
+ pgws_register_wait_collector (void )
41
41
{
42
42
BackgroundWorker worker ;
43
43
@@ -48,7 +48,7 @@ register_wait_collector(void)
48
48
worker .bgw_restart_time = 1 ;
49
49
worker .bgw_notify_pid = 0 ;
50
50
snprintf (worker .bgw_library_name , BGW_MAXLEN , "pg_wait_sampling" );
51
- snprintf (worker .bgw_function_name , BGW_MAXLEN , CppAsString (collector_main ));
51
+ snprintf (worker .bgw_function_name , BGW_MAXLEN , CppAsString (pgws_collector_main ));
52
52
snprintf (worker .bgw_name , BGW_MAXLEN , "pg_wait_sampling collector" );
53
53
worker .bgw_main_arg = (Datum ) 0 ;
54
54
RegisterBackgroundWorker (& worker );
@@ -57,7 +57,7 @@ register_wait_collector(void)
57
57
/*
58
58
* Allocate memory for waits history.
59
59
*/
60
- void
60
+ static void
61
61
alloc_history (History * observations , int count )
62
62
{
63
63
observations -> items = (HistoryItem * ) palloc0 (sizeof (HistoryItem ) * count );
@@ -151,7 +151,7 @@ probe_waits(History *observations, HTAB *profile_hash,
151
151
TimestampTz ts = GetCurrentTimestamp ();
152
152
153
153
/* Realloc waits history if needed */
154
- newSize = collector_hdr -> historySize ;
154
+ newSize = pgws_collector_hdr -> historySize ;
155
155
if (observations -> count != newSize )
156
156
realloc_history (observations , newSize );
157
157
@@ -173,8 +173,8 @@ probe_waits(History *observations, HTAB *profile_hash,
173
173
item .pid = proc -> pid ;
174
174
item .wait_event_info = proc -> wait_event_info ;
175
175
176
- if (collector_hdr -> profileQueries )
177
- item .queryId = proc_queryids [i ];
176
+ if (pgws_collector_hdr -> profileQueries )
177
+ item .queryId = pgws_proc_queryids [i ];
178
178
else
179
179
item .queryId = 0 ;
180
180
@@ -292,7 +292,7 @@ make_profile_hash()
292
292
hash_ctl .hash = tag_hash ;
293
293
hash_ctl .hcxt = TopMemoryContext ;
294
294
295
- if (collector_hdr -> profileQueries )
295
+ if (pgws_collector_hdr -> profileQueries )
296
296
hash_ctl .keysize = offsetof(ProfileItem , count );
297
297
else
298
298
hash_ctl .keysize = offsetof(ProfileItem , queryId );
@@ -321,7 +321,7 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
321
321
* Main routine of wait history collector.
322
322
*/
323
323
void
324
- collector_main (Datum main_arg )
324
+ pgws_collector_main (Datum main_arg )
325
325
{
326
326
HTAB * profile_hash = NULL ;
327
327
History observations ;
@@ -358,13 +358,13 @@ collector_main(Datum main_arg)
358
358
pgstat_report_appname ("pg_wait_sampling collector" );
359
359
360
360
profile_hash = make_profile_hash ();
361
- collector_hdr -> latch = & MyProc -> procLatch ;
361
+ pgws_collector_hdr -> latch = & MyProc -> procLatch ;
362
362
363
363
CurrentResourceOwner = ResourceOwnerCreate (NULL , "pg_wait_sampling collector" );
364
364
collector_context = AllocSetContextCreate (TopMemoryContext ,
365
365
"pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
366
366
old_context = MemoryContextSwitchTo (collector_context );
367
- alloc_history (& observations , collector_hdr -> historySize );
367
+ alloc_history (& observations , pgws_collector_hdr -> historySize );
368
368
MemoryContextSwitchTo (old_context );
369
369
370
370
ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
@@ -391,16 +391,16 @@ collector_main(Datum main_arg)
391
391
392
392
history_diff = millisecs_diff (history_ts , current_ts );
393
393
profile_diff = millisecs_diff (profile_ts , current_ts );
394
- history_period = collector_hdr -> historyPeriod ;
395
- profile_period = collector_hdr -> profilePeriod ;
394
+ history_period = pgws_collector_hdr -> historyPeriod ;
395
+ profile_period = pgws_collector_hdr -> profilePeriod ;
396
396
397
397
write_history = (history_diff >= (int64 )history_period );
398
398
write_profile = (profile_diff >= (int64 )profile_period );
399
399
400
400
if (write_history || write_profile )
401
401
{
402
402
probe_waits (& observations , profile_hash ,
403
- write_history , write_profile , collector_hdr -> profilePid );
403
+ write_history , write_profile , pgws_collector_hdr -> profilePid );
404
404
405
405
if (write_history )
406
406
{
@@ -439,24 +439,24 @@ collector_main(Datum main_arg)
439
439
ResetLatch (& MyProc -> procLatch );
440
440
441
441
/* Handle request if any */
442
- if (collector_hdr -> request != NO_REQUEST )
442
+ if (pgws_collector_hdr -> request != NO_REQUEST )
443
443
{
444
444
LOCKTAG tag ;
445
445
SHMRequest request ;
446
446
447
- init_lock_tag (& tag , PGWS_COLLECTOR_LOCK );
447
+ pgws_init_lock_tag (& tag , PGWS_COLLECTOR_LOCK );
448
448
449
449
LockAcquire (& tag , ExclusiveLock , false, false);
450
- request = collector_hdr -> request ;
451
- collector_hdr -> request = NO_REQUEST ;
450
+ request = pgws_collector_hdr -> request ;
451
+ pgws_collector_hdr -> request = NO_REQUEST ;
452
452
453
453
if (request == HISTORY_REQUEST || request == PROFILE_REQUEST )
454
454
{
455
455
shm_mq_result mq_result ;
456
456
457
457
/* Send history or profile */
458
- shm_mq_set_sender (collector_mq , MyProc );
459
- mqh = shm_mq_attach (collector_mq , NULL , NULL );
458
+ shm_mq_set_sender (pgws_collector_mq , MyProc );
459
+ mqh = shm_mq_attach (pgws_collector_mq , NULL , NULL );
460
460
mq_result = shm_mq_wait_for_attach (mqh );
461
461
switch (mq_result )
462
462
{
@@ -482,7 +482,7 @@ collector_main(Datum main_arg)
482
482
default :
483
483
AssertState (false);
484
484
}
485
- shm_mq_detach_compat (mqh , collector_mq );
485
+ shm_mq_detach_compat (mqh , pgws_collector_mq );
486
486
}
487
487
else if (request == PROFILE_RESET )
488
488
{
0 commit comments