Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit be8d6c5

Browse files
committed
Make stats_temp_directory PGC_SIGHUP, and document how it may cause a temporary
"outage" of the statistics views. This requires making the stats collector respond to SIGHUP, like the other utility processes already did.
1 parent 8c032ad commit be8d6c5

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

doc/src/sgml/config.sgml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.187 2008/08/22 18:47:07 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.188 2008/08/25 15:11:00 mha Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -3418,7 +3418,9 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
34183418
path relative to the data directory or an absolute path. The default is
34193419
<filename>pg_stat_tmp</filename>. Pointing this at a RAM based filesystem
34203420
will decrease physical I/O requirements and can lead to increased
3421-
performance. This parameter can only be set at server start.
3421+
performance. If this parameter is changed when the system is running,
3422+
the statistics functions might return no information until a new
3423+
file has been written, which typically happens twice per second.
34223424
</para>
34233425
</listitem>
34243426
</varlistentry>

src/backend/postmaster/pgstat.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
1515
*
16-
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.179 2008/08/15 08:37:39 mha Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.180 2008/08/25 15:11:00 mha Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -203,6 +203,7 @@ static PgStat_GlobalStats globalStats;
203203

204204
static volatile bool need_exit = false;
205205
static volatile bool need_statwrite = false;
206+
static volatile bool got_SIGHUP = false;
206207

207208
/*
208209
* Total time charged to functions so far in the current backend.
@@ -224,6 +225,7 @@ NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]);
224225
static void pgstat_exit(SIGNAL_ARGS);
225226
static void force_statwrite(SIGNAL_ARGS);
226227
static void pgstat_beshutdown_hook(int code, Datum arg);
228+
static void pgstat_sighup_handler(SIGNAL_ARGS);
227229

228230
static PgStat_StatDBEntry *pgstat_get_db_entry(Oid databaseid, bool create);
229231
static void pgstat_write_statsfile(bool permanent);
@@ -2571,7 +2573,7 @@ PgstatCollectorMain(int argc, char *argv[])
25712573
* Ignore all signals usually bound to some action in the postmaster,
25722574
* except SIGQUIT and SIGALRM.
25732575
*/
2574-
pqsignal(SIGHUP, SIG_IGN);
2576+
pqsignal(SIGHUP, pgstat_sighup_handler);
25752577
pqsignal(SIGINT, SIG_IGN);
25762578
pqsignal(SIGTERM, SIG_IGN);
25772579
pqsignal(SIGQUIT, pgstat_exit);
@@ -2634,6 +2636,15 @@ PgstatCollectorMain(int argc, char *argv[])
26342636
if (need_exit)
26352637
break;
26362638

2639+
/*
2640+
* Reload configuration if we got SIGHUP from the postmaster.
2641+
*/
2642+
if (got_SIGHUP)
2643+
{
2644+
ProcessConfigFile(PGC_SIGHUP);
2645+
got_SIGHUP = false;
2646+
}
2647+
26372648
/*
26382649
* If time to write the stats file, do so. Note that the alarm
26392650
* interrupt isn't re-enabled immediately, but only after we next
@@ -2834,6 +2845,13 @@ force_statwrite(SIGNAL_ARGS)
28342845
need_statwrite = true;
28352846
}
28362847

2848+
/* SIGHUP handler for collector process */
2849+
static void
2850+
pgstat_sighup_handler(SIGNAL_ARGS)
2851+
{
2852+
got_SIGHUP = true;
2853+
}
2854+
28372855

28382856
/*
28392857
* Lookup the hash table entry for the specified database. If no hash

src/backend/postmaster/postmaster.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.561 2008/06/26 02:47:19 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.562 2008/08/25 15:11:01 mha Exp $
4141
*
4242
* NOTES
4343
*
@@ -1923,7 +1923,8 @@ SIGHUP_handler(SIGNAL_ARGS)
19231923
signal_child(PgArchPID, SIGHUP);
19241924
if (SysLoggerPID != 0)
19251925
signal_child(SysLoggerPID, SIGHUP);
1926-
/* PgStatPID does not currently need SIGHUP */
1926+
if (PgStatPID != 0)
1927+
signal_child(PgStatPID, SIGHUP);
19271928

19281929
/* Reload authentication config files too */
19291930
load_hba();

src/backend/utils/misc/guc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.469 2008/08/22 18:47:07 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.470 2008/08/25 15:11:00 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -2470,7 +2470,7 @@ static struct config_string ConfigureNamesString[] =
24702470
},
24712471

24722472
{
2473-
{"stats_temp_directory", PGC_POSTMASTER, STATS_COLLECTOR,
2473+
{"stats_temp_directory", PGC_SIGHUP, STATS_COLLECTOR,
24742474
gettext_noop("Writes temporary statistics files to the specified directory."),
24752475
NULL,
24762476
GUC_SUPERUSER_ONLY

0 commit comments

Comments
 (0)