Skip to content

Commit 3947ef5

Browse files
akorotkovildus
authored andcommitted
Move all GUCs to private memory, PGC_POSTMASTER.
1 parent 0d06faf commit 3947ef5

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

Diff for: contrib/pg_stat_wait/collector.c

+7-17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ shm_toc *toc;
2727
shm_mq *mq;
2828
static volatile sig_atomic_t shutdown_requested = false;
2929

30+
int historySize;
31+
int historyPeriod;
32+
bool historySkipLatch;
33+
3034
static void handle_sigterm(SIGNAL_ARGS);
3135
static void collector_main(Datum main_arg);
3236

@@ -66,20 +70,6 @@ AllocateCollectorMem(void)
6670

6771
mq_mem = shm_toc_allocate(toc, COLLECTOR_QUEUE_SIZE);
6872
shm_toc_insert(toc, 1, mq_mem);
69-
70-
DefineCustomIntVariable("pg_stat_wait.history_size",
71-
"Sets size of waits history.", NULL,
72-
&hdr->historySize, 5000, 100, INT_MAX,
73-
PGC_SUSET, 0, NULL, NULL, NULL);
74-
75-
DefineCustomIntVariable("pg_stat_wait.history_period",
76-
"Sets period of waits history sampling.", NULL,
77-
&hdr->historyPeriod, 10, 1, INT_MAX,
78-
PGC_SUSET, 0, NULL, NULL, NULL);
79-
80-
DefineCustomBoolVariable("pg_stat_wait.history_skip_latch",
81-
"Skip latch events in waits history", NULL,
82-
&hdr->historySkipLatch, false, PGC_SUSET, 0, NULL, NULL, NULL);
8373
}
8474
else
8575
{
@@ -185,7 +175,7 @@ write_waits_history(History *observations, TimestampTz current_ts)
185175

186176
if (stateOk)
187177
{
188-
if (hdr->historySkipLatch && item.classId == WAIT_LATCH)
178+
if (historySkipLatch && item.classId == WAIT_LATCH)
189179
continue;
190180

191181
item.ts = current_ts;
@@ -241,7 +231,7 @@ collector_main(Datum main_arg)
241231
ALLOCSET_DEFAULT_INITSIZE,
242232
ALLOCSET_DEFAULT_MAXSIZE);
243233
old_context = MemoryContextSwitchTo(collector_context);
244-
AllocHistory(&observations, hdr->historySize);
234+
AllocHistory(&observations, historySize);
245235
MemoryContextSwitchTo(old_context);
246236

247237
while (1)
@@ -258,7 +248,7 @@ collector_main(Datum main_arg)
258248

259249
rc = WaitLatch(&MyProc->procLatch,
260250
WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
261-
hdr->historyPeriod);
251+
historyPeriod);
262252

263253
if (rc & WL_POSTMASTER_DEATH)
264254
exit(1);

Diff for: contrib/pg_stat_wait/pg_stat_wait.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,21 @@ _PG_init(void)
4949
return;
5050

5151
DefineCustomBoolVariable("pg_stat_wait.history", "Collect waits history",
52-
NULL, &WaitsHistoryOn, false, PGC_SUSET, 0, NULL, NULL, NULL);
52+
NULL, &WaitsHistoryOn, false, PGC_POSTMASTER, 0, NULL, NULL, NULL);
53+
54+
DefineCustomIntVariable("pg_stat_wait.history_size",
55+
"Sets size of waits history.", NULL,
56+
&historySize, 5000, 100, INT_MAX,
57+
PGC_POSTMASTER, 0, NULL, NULL, NULL);
58+
59+
DefineCustomIntVariable("pg_stat_wait.history_period",
60+
"Sets period of waits history sampling.", NULL,
61+
&historyPeriod, 10, 1, INT_MAX,
62+
PGC_POSTMASTER, 0, NULL, NULL, NULL);
63+
64+
DefineCustomBoolVariable("pg_stat_wait.history_skip_latch",
65+
"Skip latch events in waits history", NULL,
66+
&historySkipLatch, false, PGC_POSTMASTER, 0, NULL, NULL, NULL);
5367

5468
if (WaitsHistoryOn)
5569
{

Diff for: contrib/pg_stat_wait/pg_stat_wait.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ typedef struct
6262
{
6363
Latch *latch;
6464
SHMRequest request;
65-
int historySize;
66-
int historyPeriod;
67-
bool historySkipLatch;
6865
} CollectorShmqHeader;
6966

7067
extern PGDLLIMPORT char *WAIT_LOCK_NAMES[];
7168
extern PGDLLIMPORT char *WAIT_LWLOCK_NAMES[];
7269
extern PGDLLIMPORT char *WAIT_IO_NAMES[];
7370
extern PGDLLIMPORT char *WAIT_NETWORK_NAMES[];
7471
extern PGDLLIMPORT const int WAIT_OFFSETS[];
72+
extern PGDLLIMPORT int historySize;
73+
extern PGDLLIMPORT int historyPeriod;
74+
extern PGDLLIMPORT bool historySkipLatch;
75+
7576

7677
Size CollectorShmemSize(void);
7778
void AllocateCollectorMem(void);

0 commit comments

Comments
 (0)