Skip to content

Commit 62c9e81

Browse files
maksm90akorotkov
authored andcommitted
Make collector is accessable as postgres worker and visible in pg_stat_activity
1 parent a86ac9b commit 62c9e81

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

collector.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ millisecs_diff(TimestampTz tz1, TimestampTz tz2)
281281
void
282282
collector_main(Datum main_arg)
283283
{
284-
HTAB *profile_hash = NULL;
284+
HTAB *profile_hash = NULL;
285285
History observations;
286286
MemoryContext old_context,
287287
collector_context;
@@ -302,6 +302,12 @@ collector_main(Datum main_arg)
302302
pqsignal(SIGTERM, handle_sigterm);
303303
BackgroundWorkerUnblockSignals();
304304

305+
InitPostgres(NULL, InvalidOid, NULL, InvalidOid, NULL, false);
306+
SetProcessingMode(NormalProcessing);
307+
308+
/* Make pg_wait_sampling recognisable in pg_stat_activity */
309+
pgstat_report_appname("pg_wait_sampling collector");
310+
305311
profile_hash = make_profile_hash();
306312
collector_hdr->latch = &MyProc->procLatch;
307313

@@ -312,6 +318,8 @@ collector_main(Datum main_arg)
312318
alloc_history(&observations, collector_hdr->historySize);
313319
MemoryContextSwitchTo(old_context);
314320

321+
ereport(LOG, (errmsg("pg_wait_sampling collector started")));
322+
315323
/* Start counting time for history and profile samples */
316324
profile_ts = history_ts = GetCurrentTimestamp();
317325

@@ -430,5 +438,6 @@ collector_main(Datum main_arg)
430438
* on_dsm_detach callbacks we've registered, as well. Once that's done,
431439
* we can go ahead and exit.
432440
*/
441+
ereport(LOG, (errmsg("pg_wait_sampling collector shutting down")));
433442
proc_exit(0);
434443
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy