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,
151152TimestampTz ts = GetCurrentTimestamp ();
152153
153154/* Realloc waits history if needed */
154- newSize = pgws_collector_hdr -> historySize ;
155+ newSize = pgws_historySize ;
155156if (observations -> count != newSize )
156157realloc_history (observations ,newSize );
157158
@@ -170,7 +171,7 @@ probe_waits(History *observations, HTAB *profile_hash,
170171item .pid = proc -> pid ;
171172item .wait_event_info = proc -> wait_event_info ;
172173
173- if (pgws_collector_hdr -> profileQueries )
174+ if (pgws_profileQueries )
174175item .queryId = pgws_proc_queryids [i ];
175176else
176177item .queryId = 0 ;
@@ -289,7 +290,7 @@ make_profile_hash()
289290hash_ctl .hash = tag_hash ;
290291hash_ctl .hcxt = TopMemoryContext ;
291292
292- if (pgws_collector_hdr -> profileQueries )
293+ if (pgws_profileQueries )
293294hash_ctl .keysize = offsetof(ProfileItem ,count );
294295else
295296hash_ctl .keysize = offsetof(ProfileItem ,queryId );
@@ -346,6 +347,7 @@ pgws_collector_main(Datum main_arg)
346347 * partitipate to the ProcSignal infrastructure.
347348 */
348349pqsignal (SIGTERM ,handle_sigterm );
350+ pqsignal (SIGHUP ,SignalHandlerForConfigReload );
349351pqsignal (SIGUSR1 ,procsignal_sigusr1_handler );
350352BackgroundWorkerUnblockSignals ();
351353InitPostgresCompat (NULL ,InvalidOid ,NULL ,InvalidOid ,0 ,NULL );
@@ -361,7 +363,7 @@ pgws_collector_main(Datum main_arg)
361363collector_context = AllocSetContextCreate (TopMemoryContext ,
362364"pg_wait_sampling context" ,ALLOCSET_DEFAULT_SIZES );
363365old_context = MemoryContextSwitchTo (collector_context );
364- alloc_history (& observations ,pgws_collector_hdr -> historySize );
366+ alloc_history (& observations ,pgws_historySize );
365367MemoryContextSwitchTo (old_context );
366368
367369ereport (LOG , (errmsg ("pg_wait_sampling collector started" )));
@@ -375,29 +377,31 @@ pgws_collector_main(Datum main_arg)
375377shm_mq_handle * mqh ;
376378int64 history_diff ,
377379profile_diff ;
378- int history_period ,
379- profile_period ;
380380bool write_history ,
381381write_profile ;
382382
383383/* We need an explicit call for at least ProcSignal notifications. */
384384CHECK_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 */
387393current_ts = GetCurrentTimestamp ();
388394
389395history_diff = millisecs_diff (history_ts ,current_ts );
390396profile_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
397401if (write_history || write_profile )
398402{
399403probe_waits (& observations ,profile_hash ,
400- write_history ,write_profile ,pgws_collector_hdr -> profilePid );
404+ write_history ,write_profile ,pgws_profilePid );
401405
402406if (write_history )
403407{
@@ -421,8 +425,8 @@ pgws_collector_main(Datum main_arg)
421425 * shared memory.
422426 */
423427rc = 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
427431if (rc & WL_POSTMASTER_DEATH )
428432proc_exit (1 );