diff options
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/autovacuum.c | 28 | ||||
| -rw-r--r-- | src/backend/postmaster/pgstat.c | 94 |
2 files changed, 34 insertions, 88 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 8866f287ca1..7c9b7f72b6c 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -55,7 +55,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.59 2007/09/23 20:07:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.60 2007/09/24 03:12:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -114,7 +114,7 @@ int autovacuum_freeze_max_age; int autovacuum_vac_cost_delay; int autovacuum_vac_cost_limit; -int Log_autovacuum = -1; +int Log_autovacuum_min_duration = -1; /* Flags to tell if we are in an autovacuum process */ @@ -511,7 +511,7 @@ AutoVacLauncherMain(int argc, char *argv[]) PG_SETMASK(&UnBlockSig); /* in emergency mode, just start a worker and go away */ - if (!autovacuum_start_daemon) + if (!AutoVacuumingActive()) { do_start_worker(); proc_exit(0); /* done */ @@ -590,7 +590,7 @@ AutoVacLauncherMain(int argc, char *argv[]) ProcessConfigFile(PGC_SIGHUP); /* shutdown requested in config file */ - if (!autovacuum_start_daemon) + if (!AutoVacuumingActive()) break; /* rebalance in case the default cost parameters changed */ @@ -2625,8 +2625,7 @@ autovac_report_activity(VacuumStmt *vacstmt, Oid relid) bool AutoVacuumingActive(void) { - if (!autovacuum_start_daemon || !pgstat_collect_startcollector || - !pgstat_collect_tuplelevel) + if (!autovacuum_start_daemon || !pgstat_track_counts) return false; return true; } @@ -2635,26 +2634,15 @@ AutoVacuumingActive(void) * autovac_init * This is called at postmaster initialization. * - * Annoy the user if he got it wrong. + * All we do here is annoy the user if he got it wrong. */ void autovac_init(void) { - if (!autovacuum_start_daemon) - return; - - if (!pgstat_collect_startcollector || !pgstat_collect_tuplelevel) - { + if (autovacuum_start_daemon && !pgstat_track_counts) ereport(WARNING, (errmsg("autovacuum not started because of misconfiguration"), - errhint("Enable options \"stats_start_collector\" and \"stats_row_level\"."))); - - /* - * Set the GUC var so we don't fork autovacuum uselessly, and also to - * help debugging. - */ - autovacuum_start_daemon = false; - } + errhint("Enable the \"track_counts\" option."))); } /* diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 9e088780d4c..20ae5be6c99 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -13,7 +13,7 @@ * * Copyright (c) 2001-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.164 2007/09/20 17:56:31 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.165 2007/09/24 03:12:23 tgl Exp $ * ---------- */ #include "postgres.h" @@ -55,6 +55,7 @@ #include "storage/ipc.h" #include "storage/pg_shmem.h" #include "storage/pmsignal.h" +#include "utils/guc.h" #include "utils/memutils.h" #include "utils/ps_status.h" @@ -93,11 +94,8 @@ * GUC parameters * ---------- */ -bool pgstat_collect_startcollector = true; -bool pgstat_collect_resetonpmstart = false; -bool pgstat_collect_tuplelevel = false; -bool pgstat_collect_blocklevel = false; -bool pgstat_collect_querystring = false; +bool pgstat_track_activities = false; +bool pgstat_track_counts = false; /* * BgWriter global statistics counters (unused in other processes). @@ -257,28 +255,6 @@ pgstat_init(void) #define TESTBYTEVAL ((char) 199) /* - * Force start of collector daemon if something to collect. Note that - * pgstat_collect_querystring is now an independent facility that does not - * require the collector daemon. - */ - if (pgstat_collect_tuplelevel || - pgstat_collect_blocklevel) - pgstat_collect_startcollector = true; - - /* - * If we don't have to start a collector or should reset the collected - * statistics on postmaster start, simply remove the stats file. - */ - if (!pgstat_collect_startcollector || pgstat_collect_resetonpmstart) - pgstat_reset_all(); - - /* - * Nothing else required if collector will not get started - */ - if (!pgstat_collect_startcollector) - return; - - /* * Create the UDP socket for sending and receiving statistic messages */ hints.ai_flags = AI_PASSIVE; @@ -492,17 +468,19 @@ startup_failed: closesocket(pgStatSock); pgStatSock = -1; - /* Adjust GUC variables to suppress useless activity */ - pgstat_collect_startcollector = false; - pgstat_collect_tuplelevel = false; - pgstat_collect_blocklevel = false; + /* + * Adjust GUC variables to suppress useless activity, and for debugging + * purposes (seeing track_counts off is a clue that we failed here). + * We use PGC_S_OVERRIDE because there is no point in trying to turn it + * back on from postgresql.conf without a restart. + */ + SetConfigOption("track_counts", "off", PGC_INTERNAL, PGC_S_OVERRIDE); } /* * pgstat_reset_all() - * - * Remove the stats file. This is used on server start if the - * stats_reset_on_server_start feature is enabled, or if WAL + * Remove the stats file. This is currently used only if WAL * recovery is needed after a crash. */ void @@ -536,7 +514,7 @@ pgstat_forkexec(void) #endif /* EXEC_BACKEND */ -/* ---------- +/* * pgstat_start() - * * Called from postmaster at startup or after an existing collector @@ -545,7 +523,6 @@ pgstat_forkexec(void) * Returns PID of child process, or 0 if fail. * * Note: if fail, we will be called again from the postmaster main loop. - * ---------- */ int pgstat_start(void) @@ -554,9 +531,10 @@ pgstat_start(void) pid_t pgStatPid; /* - * Do nothing if no collector needed + * Check that the socket is there, else pgstat_init failed and we can + * do nothing useful. */ - if (!pgstat_collect_startcollector) + if (pgStatSock < 0) return 0; /* @@ -572,22 +550,6 @@ pgstat_start(void) last_pgstat_start_time = curtime; /* - * Check that the socket is there, else pgstat_init failed. - */ - if (pgStatSock < 0) - { - ereport(LOG, - (errmsg("statistics collector startup skipped"))); - - /* - * We can only get here if someone tries to manually turn - * pgstat_collect_startcollector on after it had been off. - */ - pgstat_collect_startcollector = false; - return 0; - } - - /* * Okay, fork off the collector. */ #ifdef EXEC_BACKEND @@ -1052,8 +1014,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared, { PgStat_MsgVacuum msg; - if (pgStatSock < 0 || - !pgstat_collect_tuplelevel) + if (pgStatSock < 0 || !pgstat_track_counts) return; pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_VACUUM); @@ -1078,8 +1039,7 @@ pgstat_report_analyze(Oid tableoid, bool shared, PgStat_Counter livetuples, { PgStat_MsgAnalyze msg; - if (pgStatSock < 0 || - !pgstat_collect_tuplelevel) + if (pgStatSock < 0 || !pgstat_track_counts) return; pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_ANALYZE); @@ -1139,9 +1099,7 @@ pgstat_initstats(Relation rel) return; } - if (pgStatSock < 0 || - !(pgstat_collect_tuplelevel || - pgstat_collect_blocklevel)) + if (pgStatSock < 0 || !pgstat_track_counts) { /* We're not counting at all */ rel->pgstat_info = NULL; @@ -1274,7 +1232,7 @@ pgstat_count_heap_insert(Relation rel) { PgStat_TableStatus *pgstat_info = rel->pgstat_info; - if (pgstat_collect_tuplelevel && pgstat_info != NULL) + if (pgstat_track_counts && pgstat_info != NULL) { int nest_level = GetCurrentTransactionNestLevel(); @@ -1298,7 +1256,7 @@ pgstat_count_heap_update(Relation rel, bool hot) { PgStat_TableStatus *pgstat_info = rel->pgstat_info; - if (pgstat_collect_tuplelevel && pgstat_info != NULL) + if (pgstat_track_counts && pgstat_info != NULL) { int nest_level = GetCurrentTransactionNestLevel(); @@ -1327,7 +1285,7 @@ pgstat_count_heap_delete(Relation rel) { PgStat_TableStatus *pgstat_info = rel->pgstat_info; - if (pgstat_collect_tuplelevel && pgstat_info != NULL) + if (pgstat_track_counts && pgstat_info != NULL) { int nest_level = GetCurrentTransactionNestLevel(); @@ -1356,7 +1314,7 @@ pgstat_update_heap_dead_tuples(Relation rel, int delta) { PgStat_TableStatus *pgstat_info = rel->pgstat_info; - if (pgstat_collect_tuplelevel && pgstat_info != NULL) + if (pgstat_track_counts && pgstat_info != NULL) pgstat_info->t_counts.t_new_dead_tuples -= delta; } @@ -1931,7 +1889,7 @@ pgstat_report_activity(const char *cmd_str) TimestampTz start_timestamp; int len; - if (!pgstat_collect_querystring || !beentry) + if (!pgstat_track_activities || !beentry) return; /* @@ -1967,7 +1925,7 @@ pgstat_report_xact_timestamp(TimestampTz tstamp) { volatile PgBackendStatus *beentry = MyBEEntry; - if (!pgstat_collect_querystring || !beentry) + if (!pgstat_track_activities || !beentry) return; /* @@ -1995,7 +1953,7 @@ pgstat_report_waiting(bool waiting) { volatile PgBackendStatus *beentry = MyBEEntry; - if (!pgstat_collect_querystring || !beentry) + if (!pgstat_track_activities || !beentry) return; /* |
