16
16
#include "funcapi.h"
17
17
#include "miscadmin.h"
18
18
#include "postmaster/bgworker.h"
19
+ #include "postmaster/interrupt.h"
19
20
#include "storage/ipc.h"
20
21
#include "storage/procarray.h"
21
22
#include "storage/procsignal.h"
@@ -151,7 +152,7 @@ probe_waits(History *observations, HTAB *profile_hash,
151
152
TimestampTz ts = GetCurrentTimestamp ();
152
153
153
154
/* Realloc waits history if needed */
154
- newSize = pgws_collector_hdr -> historySize ;
155
+ newSize = pgws_historySize ;
155
156
if (observations -> count != newSize )
156
157
realloc_history (observations , newSize );
157
158
@@ -170,7 +171,7 @@ probe_waits(History *observations, HTAB *profile_hash,
170
171
item .pid = proc -> pid ;
171
172
item .wait_event_info = proc -> wait_event_info ;
172
173
173
- if (pgws_collector_hdr -> profileQueries )
174
+ if (pgws_profileQueries )
174
175
item .queryId = pgws_proc_queryids [i ];
175
176
else
176
177
item .queryId = 0 ;
@@ -289,7 +290,7 @@ make_profile_hash()
289
290
hash_ctl .hash = tag_hash ;
290
291
hash_ctl .hcxt = TopMemoryContext ;
291
292
292
- if (pgws_collector_hdr -> profileQueries )
293
+ if (pgws_profileQueries )
293
294
hash_ctl .keysize = offsetof(ProfileItem , count );
294
295
else
295
296
hash_ctl .keysize = offsetof(ProfileItem , queryId );
@@ -346,6 +347,7 @@ pgws_collector_main(Datum main_arg)
346
347
* partitipate to the ProcSignal infrastructure.
347
348
*/
348
349
pqsignal (SIGTERM , handle_sigterm );
350
+ pqsignal (SIGHUP , SignalHandlerForConfigReload );
349
351
pqsignal (SIGUSR1 , procsignal_sigusr1_handler );
350
352
BackgroundWorkerUnblockSignals ();
351
353
InitPostgresCompat (NULL , InvalidOid , NULL , InvalidOid , 0 , NULL );
@@ -361,7 +363,7 @@ pgws_collector_main(Datum main_arg)
361
363
collector_context = AllocSetContextCreate (TopMemoryContext ,
362
364
"pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
363
365
old_context = MemoryContextSwitchTo (collector_context );
364
- alloc_history (& observations , pgws_collector_hdr -> historySize );
366
+ alloc_history (& observations , pgws_historySize );
365
367
MemoryContextSwitchTo (old_context );
366
368
367
369
ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
@@ -375,29 +377,31 @@ pgws_collector_main(Datum main_arg)
375
377
shm_mq_handle * mqh ;
376
378
int64 history_diff ,
377
379
profile_diff ;
378
- int history_period ,
379
- profile_period ;
380
380
bool write_history ,
381
381
write_profile ;
382
382
383
383
/* We need an explicit call for at least ProcSignal notifications. */
384
384
CHECK_FOR_INTERRUPTS ();
385
385
386
+ if (ConfigReloadPending )
387
+ {
388
+ ConfigReloadPending = false;
389
+ ProcessConfigFile (PGC_SIGHUP );
390
+ }
391
+
386
392
/* Wait calculate time to next sample for history or profile */
387
393
current_ts = GetCurrentTimestamp ();
388
394
389
395
history_diff = millisecs_diff (history_ts , current_ts );
390
396
profile_diff = millisecs_diff (profile_ts , current_ts );
391
- history_period = pgws_collector_hdr -> historyPeriod ;
392
- profile_period = pgws_collector_hdr -> profilePeriod ;
393
397
394
- write_history = (history_diff >= (int64 )history_period );
395
- write_profile = (profile_diff >= (int64 )profile_period );
398
+ write_history = (history_diff >= (int64 )pgws_historyPeriod );
399
+ write_profile = (profile_diff >= (int64 )pgws_profilePeriod );
396
400
397
401
if (write_history || write_profile )
398
402
{
399
403
probe_waits (& observations , profile_hash ,
400
- write_history , write_profile , pgws_collector_hdr -> profilePid );
404
+ write_history , write_profile , pgws_profilePid );
401
405
402
406
if (write_history )
403
407
{
@@ -421,8 +425,8 @@ pgws_collector_main(Datum main_arg)
421
425
* shared memory.
422
426
*/
423
427
rc = WaitLatch (& MyProc -> procLatch , WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
424
- Min (history_period - (int )history_diff ,
425
- profile_period - (int )profile_diff ), PG_WAIT_EXTENSION );
428
+ Min (pgws_historyPeriod - (int )history_diff ,
429
+ pgws_historyPeriod - (int )profile_diff ), PG_WAIT_EXTENSION );
426
430
427
431
if (rc & WL_POSTMASTER_DEATH )
428
432
proc_exit (1 );
0 commit comments