1616#include "funcapi.h"
1717#include "miscadmin.h"
1818#include "postmaster/bgworker.h"
19+ #include "postmaster/interrupt.h"
1920#include "storage/ipc.h"
2021#include "storage/procarray.h"
2122#include "storage/procsignal.h"
@@ -151,7 +152,7 @@ probe_waits(History *observations, HTAB *profile_hash,
151152 TimestampTz ts = GetCurrentTimestamp ();
152153
153154 /* Realloc waits history if needed */
154- newSize = pgws_collector_hdr -> historySize ;
155+ newSize = pgws_historySize ;
155156 if (observations -> count != newSize )
156157 realloc_history (observations , newSize );
157158
@@ -170,7 +171,7 @@ probe_waits(History *observations, HTAB *profile_hash,
170171 item .pid = proc -> pid ;
171172 item .wait_event_info = proc -> wait_event_info ;
172173
173- if (pgws_collector_hdr -> profileQueries )
174+ if (pgws_profileQueries )
174175 item .queryId = pgws_proc_queryids [i ];
175176 else
176177 item .queryId = 0 ;
@@ -289,7 +290,7 @@ make_profile_hash()
289290 hash_ctl .hash = tag_hash ;
290291 hash_ctl .hcxt = TopMemoryContext ;
291292
292- if (pgws_collector_hdr -> profileQueries )
293+ if (pgws_profileQueries )
293294 hash_ctl .keysize = offsetof(ProfileItem , count );
294295 else
295296 hash_ctl .keysize = offsetof(ProfileItem , queryId );
@@ -346,6 +347,7 @@ pgws_collector_main(Datum main_arg)
346347 * partitipate to the ProcSignal infrastructure.
347348 */
348349 pqsignal (SIGTERM , handle_sigterm );
350+ pqsignal (SIGHUP , SignalHandlerForConfigReload );
349351 pqsignal (SIGUSR1 , procsignal_sigusr1_handler );
350352 BackgroundWorkerUnblockSignals ();
351353 InitPostgresCompat (NULL , InvalidOid , NULL , InvalidOid , 0 , NULL );
@@ -361,7 +363,7 @@ pgws_collector_main(Datum main_arg)
361363 collector_context = AllocSetContextCreate (TopMemoryContext ,
362364 "pg_wait_sampling context" , ALLOCSET_DEFAULT_SIZES );
363365 old_context = MemoryContextSwitchTo (collector_context );
364- alloc_history (& observations , pgws_collector_hdr -> historySize );
366+ alloc_history (& observations , pgws_historySize );
365367 MemoryContextSwitchTo (old_context );
366368
367369 ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
@@ -375,29 +377,31 @@ pgws_collector_main(Datum main_arg)
375377 shm_mq_handle * mqh ;
376378 int64 history_diff ,
377379 profile_diff ;
378- int history_period ,
379- profile_period ;
380380 bool write_history ,
381381 write_profile ;
382382
383383 /* We need an explicit call for at least ProcSignal notifications. */
384384 CHECK_FOR_INTERRUPTS ();
385385
386+ if (ConfigReloadPending )
387+ {
388+ ConfigReloadPending = false;
389+ ProcessConfigFile (PGC_SIGHUP );
390+ }
391+
386392 /* Wait calculate time to next sample for history or profile */
387393 current_ts = GetCurrentTimestamp ();
388394
389395 history_diff = millisecs_diff (history_ts , current_ts );
390396 profile_diff = millisecs_diff (profile_ts , current_ts );
391- history_period = pgws_collector_hdr -> historyPeriod ;
392- profile_period = pgws_collector_hdr -> profilePeriod ;
393397
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 );
396400
397401 if (write_history || write_profile )
398402 {
399403 probe_waits (& observations , profile_hash ,
400- write_history , write_profile , pgws_collector_hdr -> profilePid );
404+ write_history , write_profile , pgws_profilePid );
401405
402406 if (write_history )
403407 {
@@ -421,8 +425,8 @@ pgws_collector_main(Datum main_arg)
421425 * shared memory.
422426 */
423427 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 );
426430
427431 if (rc & WL_POSTMASTER_DEATH )
428432 proc_exit (1 );
0 commit comments