1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Back out pg_autovacuum commit after cvs clean failure causes commit.

This commit is contained in:
Bruce Momjian
2004-07-21 20:34:50 +00:00
parent 8dec0c1bf2
commit 7a55ba7615
15 changed files with 131 additions and 524 deletions

View File

@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.102 2004/07/21 20:22:58 momjian Exp $
# $PostgreSQL: pgsql/src/backend/Makefile,v 1.103 2004/07/21 20:34:44 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -29,13 +29,13 @@ endif
##########################################################################
all: submake-libpgport submake-libpq postgres $(POSTGRES_IMP)
all: submake-libpgport postgres $(POSTGRES_IMP)
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -I $(libpq_srcdir) $(export_dynamic) $^ $(LIBS) $(libpq) -o $@
$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
endif
endif

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.188 2004/07/21 20:22:58 momjian Exp $
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.189 2004/07/21 20:34:45 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,7 +34,6 @@
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
#include "postmaster/pg_autovacuum.h"
#include "storage/freespace.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
@@ -356,9 +355,6 @@ BootstrapMain(int argc, char *argv[])
case BS_XLOG_BGWRITER:
statmsg = "writer process";
break;
case BS_XLOG_AUTOVAC:
statmsg = "auto vacuum process";
break;
default:
statmsg = "??? process";
break;
@@ -395,9 +391,6 @@ BootstrapMain(int argc, char *argv[])
case BS_XLOG_BGWRITER:
InitDummyProcess(DUMMY_PROC_BGWRITER);
break;
case BS_XLOG_AUTOVAC:
InitDummyProcess(DUMMY_PROC_AUTOVAC);
break;
default:
InitDummyProcess(DUMMY_PROC_DEFAULT);
@@ -434,12 +427,6 @@ BootstrapMain(int argc, char *argv[])
BackgroundWriterMain();
proc_exit(1); /* should never return */
case BS_XLOG_AUTOVAC:
/* don't set signals, autovac has its own agenda */
InitXLOGAccess();
AutoVacMain();
proc_exit(1); /* should never return */
default:
elog(PANIC, "unrecognized XLOG op: %d", xlogop);
proc_exit(1);

View File

@@ -2,7 +2,7 @@
#
# Makefile for backend/catalog
#
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.52 2004/07/21 20:22:59 momjian Exp $
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.53 2004/07/21 20:34:45 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -32,7 +32,7 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
pg_namespace.h pg_conversion.h pg_database.h pg_shadow.h pg_group.h \
pg_tablespace.h pg_depend.h pg_autovacuum.h indexing.h \
pg_tablespace.h pg_depend.h indexing.h \
)
pg_includes := $(sort -I$(top_srcdir)/src/include -I$(top_builddir)/src/include)

View File

@@ -3,7 +3,7 @@
*
* Copyright 1996-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.7 2004/07/21 20:22:59 momjian Exp $
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.8 2004/07/21 20:34:45 momjian Exp $
*/
CREATE VIEW pg_user AS
@@ -41,26 +41,22 @@ CREATE VIEW pg_tables AS
SELECT
N.nspname AS schemaname,
C.relname AS tablename,
T.spcname AS tablespace,
pg_get_userbyid(C.relowner) AS tableowner,
C.relhasindex AS hasindexes,
C.relhasrules AS hasrules,
(C.reltriggers > 0) AS hastriggers
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
LEFT JOIN pg_tablespace T ON (T.oid = C.reltablespace)
WHERE C.relkind = 'r';
CREATE VIEW pg_indexes AS
SELECT
N.nspname AS schemaname,
C.relname AS tablename,
T.spcname AS tablespace,
I.relname AS indexname,
pg_get_indexdef(I.oid) AS indexdef
FROM pg_index X JOIN pg_class C ON (C.oid = X.indrelid)
JOIN pg_class I ON (I.oid = X.indexrelid)
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
LEFT JOIN pg_tablespace T ON (T.oid = C.reltablespace)
WHERE C.relkind = 'r' AND I.relkind = 'i';
CREATE VIEW pg_stats AS

View File

@@ -4,7 +4,7 @@
# Makefile for src/backend/postmaster
#
# IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/postmaster/Makefile,v 1.17 2004/07/21 20:22:59 momjian Exp $
# $PostgreSQL: pgsql/src/backend/postmaster/Makefile,v 1.18 2004/07/21 20:34:46 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -12,7 +12,7 @@ subdir = src/backend/postmaster
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
OBJS = postmaster.o bgwriter.o pgstat.o pgarch.o pg_autovacuum.o
OBJS = postmaster.o bgwriter.o pgstat.o pgarch.o
all: SUBSYS.o

View File

@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.413 2004/07/21 20:22:59 momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.414 2004/07/21 20:34:46 momjian Exp $
*
* NOTES
*
@@ -55,6 +55,12 @@
* The Postmaster cleans up after backends if they have an emergency
* exit and/or core dump.
*
* Error Reporting:
* Use write_stderr() only for reporting "interactive" errors
* (essentially, bogus arguments on the command line). Once the
* postmaster is launched, use ereport(). In particular, don't use
* write_stderr() for anything that occurs after pmdaemonize.
*
*-------------------------------------------------------------------------
*/
@@ -194,7 +200,6 @@ char *preload_libraries_string = NULL;
static pid_t StartupPID = 0,
BgWriterPID = 0,
PgArchPID = 0,
AutoVacPID = 0,
PgStatPID = 0;
/* Startup/shutdown state */
@@ -264,7 +269,6 @@ static void SignalChildren(int signal);
static int CountChildren(void);
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname);
static pid_t StartChildProcess(int xlop);
static void postmaster_error(const char *fmt,...);
#ifdef EXEC_BACKEND
@@ -295,7 +299,6 @@ static void ShmemBackendArrayRemove(pid_t pid);
#define StartupDataBase() StartChildProcess(BS_XLOG_STARTUP)
#define StartBackgroundWriter() StartChildProcess(BS_XLOG_BGWRITER)
#define StartAutoVac() StartChildProcess(BS_XLOG_AUTOVAC)
/*
@@ -382,7 +385,7 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_ASSERT_CHECKING
SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, PGC_S_ARGV);
#else
postmaster_error("assert checking is not compiled in");
write_stderr("%s: assert checking is not compiled in\n", progname);
#endif
break;
case 'a':
@@ -506,9 +509,8 @@ PostmasterMain(int argc, char *argv[])
}
default:
fprintf(stderr,
gettext("Try \"%s --help\" for more information.\n"),
progname);
write_stderr("Try \"%s --help\" for more information.\n",
progname);
ExitPostmaster(1);
}
}
@@ -518,10 +520,10 @@ PostmasterMain(int argc, char *argv[])
*/
if (optind < argc)
{
postmaster_error("invalid argument: \"%s\"", argv[optind]);
fprintf(stderr,
gettext("Try \"%s --help\" for more information.\n"),
progname);
write_stderr("%s: invalid argument: \"%s\"\n",
progname, argv[optind]);
write_stderr("Try \"%s --help\" for more information.\n",
progname);
ExitPostmaster(1);
}
@@ -592,13 +594,13 @@ PostmasterMain(int argc, char *argv[])
* for lack of buffers. The specific choices here are somewhat
* arbitrary.
*/
postmaster_error("the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16");
write_stderr("%s: the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16\n", progname);
ExitPostmaster(1);
}
if (ReservedBackends >= MaxBackends)
{
postmaster_error("superuser_reserved_connections must be less than max_connections");
write_stderr("%s: superuser_reserved_connections must be less than max_connections\n", progname);
ExitPostmaster(1);
}
@@ -607,7 +609,7 @@ PostmasterMain(int argc, char *argv[])
*/
if (!CheckDateTokenTables())
{
postmaster_error("invalid datetoken tables, please fix");
write_stderr("%s: invalid datetoken tables, please fix\n", progname);
ExitPostmaster(1);
}
@@ -827,7 +829,7 @@ PostmasterMain(int argc, char *argv[])
* CAUTION: when changing this list, check for side-effects on the signal
* handling setup of child processes. See tcop/postgres.c,
* bootstrap/bootstrap.c, postmaster/bgwriter.c, postmaster/pgarch.c,
* postmaster/pgstat.c, and postmaster/pg_autovacuum.c.
* and postmaster/pgstat.c.
*/
pqinitmask();
PG_SETMASK(&BlockSig);
@@ -976,11 +978,10 @@ checkDataDir(const char *checkdir)
fp = AllocateFile(path, PG_BINARY_R);
if (fp == NULL)
{
fprintf(stderr,
gettext("%s: could not find the database system\n"
"Expected to find it in the directory \"%s\",\n"
"but could not open file \"%s\": %s\n"),
progname, checkdir, path, strerror(errno));
write_stderr("%s: could not find the database system\n"
"Expected to find it in the directory \"%s\",\n"
"but could not open file \"%s\": %s\n",
progname, checkdir, path, strerror(errno));
ExitPostmaster(2);
}
FreeFile(fp);
@@ -1023,8 +1024,8 @@ pmdaemonize(void)
pid = fork();
if (pid == (pid_t) -1)
{
postmaster_error("could not fork background process: %s",
strerror(errno));
write_stderr("%s: could not fork background process: %s\n",
progname, strerror(errno));
ExitPostmaster(1);
}
else if (pid)
@@ -1045,8 +1046,8 @@ pmdaemonize(void)
#ifdef HAVE_SETSID
if (setsid() < 0)
{
postmaster_error("could not dissociate from controlling TTY: %s",
strerror(errno));
write_stderr("%s: could not dissociate from controlling TTY: %s\n",
progname, strerror(errno));
ExitPostmaster(1);
}
#endif
@@ -1113,9 +1114,9 @@ ServerLoop(void)
int nSockets;
time_t now,
last_touch_time;
struct timeval earlier,
struct timeval earlier,
later;
struct timezone tz;
struct timezone tz;
gettimeofday(&earlier, &tz);
last_touch_time = time(NULL);
@@ -1219,35 +1220,6 @@ ServerLoop(void)
kill(BgWriterPID, SIGUSR2);
}
/*
* If no AutoVacuum process is running, and we are not in
* a state that prevents it, start one. It doesn't matter if this
* fails, we'll just try again later.
*/
if (autovacuum_start_daemon)
{
if (pgstat_collect_tuplelevel)
{
if (AutoVacPID == 0 && StartupPID == 0 && !FatalError)
{
AutoVacPID = StartAutoVac();
if(pgstat_collect_resetonpmstart)
elog(WARNING,"pg_autovacuum: stats_reset_on_server_start should be disabled for optimal performance");
/* If shutdown is pending, set it going */
if (Shutdown > NoShutdown && AutoVacPID != 0)
kill(AutoVacPID, SIGUSR2);
}
}
else
elog(WARNING, "pg_autovacuum: autovac is enabled, but requires stats_row_level which is not enabled");
}
else if(AutoVacPID > 0)
kill(AutoVacPID, SIGUSR2);
if (!autovacuum_start_daemon)
elog(DEBUG1, "pg_autovacuum: not enabled");
/* If we have lost the archiver, try to start a new one */
if (XLogArchivingActive() && PgArchPID == 0 &&
StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
@@ -1615,21 +1587,6 @@ processCancelRequest(Port *port, void *pkt)
backendPID = (int) ntohl(canc->backendPID);
cancelAuthCode = (long) ntohl(canc->cancelAuthCode);
if (backendPID == BgWriterPID)
{
ereport(DEBUG2,
(errmsg_internal("ignoring cancel request for bgwriter process %d",
backendPID)));
return;
}
if (backendPID == AutoVacPID)
{
ereport(DEBUG2,
(errmsg_internal("ignoring cancel request for autovacuum process %d",
backendPID)));
return;
}
/*
* See if we have a matching backend. In the EXEC_BACKEND case, we
* can no longer access the postmaster's own backend list, and must
@@ -1813,8 +1770,6 @@ SIGHUP_handler(SIGNAL_ARGS)
kill(BgWriterPID, SIGHUP);
if (PgArchPID != 0)
kill(PgArchPID, SIGHUP);
if (AutoVacPID != 0)
kill(AutoVacPID, SIGHUP);
/* PgStatPID does not currently need SIGHUP */
load_hba();
load_ident();
@@ -1876,10 +1831,6 @@ pmdie(SIGNAL_ARGS)
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
/* I don't think we need to Start the autovac process if not running */
/* And tell it to shut down */
if (AutoVacPID != 0)
kill(AutoVacPID, SIGUSR2);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
@@ -1927,9 +1878,6 @@ pmdie(SIGNAL_ARGS)
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
/* And tell it to shut down */
if (AutoVacPID != 0)
kill(AutoVacPID, SIGUSR2);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
@@ -1950,8 +1898,6 @@ pmdie(SIGNAL_ARGS)
kill(BgWriterPID, SIGQUIT);
if (PgArchPID != 0)
kill(PgArchPID, SIGQUIT);
if (AutoVacPID != 0)
kill(AutoVacPID, SIGQUIT);
if (PgStatPID != 0)
kill(PgStatPID, SIGQUIT);
if (DLGetHead(BackendList))
@@ -2094,35 +2040,9 @@ reaper(SIGNAL_ARGS)
if (XLogArchivingActive() &&
StartupPID == 0 && !FatalError && Shutdown == NoShutdown)
PgArchPID = pgarch_start();
/*
* Shutdown autovac if a shutdown request was pending.
*/
if (Shutdown > NoShutdown && AutoVacPID != 0)
kill(AutoVacPID, SIGUSR2);
continue;
}
/*
* Was it the autovac?
*/
if (AutoVacPID != 0 && pid == AutoVacPID)
{
AutoVacPID = 0;
if (exitstatus != 0)
{
/*
* Any unexpected exit of the autovacuum is treated as a crash.
* FIXME: This is useful for debugging autovac, but I think it should be
* ripped out before final patch, autovac shouldn't crash the postmaster
*/
LogChildExit(LOG, gettext("pg_autovacuum process"),
pid, exitstatus);
HandleChildCrash(pid, exitstatus);
continue;
}
}
/*
* Was it the statistics collector? If so, just try to start a new
* one; no need to force reset of the rest of the system. (If fail,
@@ -2152,7 +2072,7 @@ reaper(SIGNAL_ARGS)
* StartupDataBase. (We can ignore the archiver and stats processes
* here since they are not connected to shmem.)
*/
if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0 || AutoVacPID != 0)
if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0)
goto reaper_done;
ereport(LOG,
(errmsg("all server processes terminated; reinitializing")));
@@ -2175,9 +2095,6 @@ reaper(SIGNAL_ARGS)
/* And tell it to shut down */
if (BgWriterPID != 0)
kill(BgWriterPID, SIGUSR2);
/* Tell AutoVac to shut down */
if (AutoVacPID != 0)
kill(AutoVacPID, SIGUSR2);
}
reaper_done:
@@ -2337,20 +2254,6 @@ HandleChildCrash(int pid,
}
FatalError = true;
/* Take care of the autovacuum too */
if (pid == AutoVacPID)
AutoVacPID = 0;
else if (AutoVacPID != 0 && !FatalError)
{
ereport(DEBUG2,
(errmsg_internal("sending %s to process %d",
(SendStop ? "SIGSTOP" : "SIGQUIT"),
(int) AutoVacPID)));
kill(AutoVacPID, (SendStop ? SIGSTOP : SIGQUIT));
}
FatalError = true;
}
/*
@@ -3337,10 +3240,6 @@ StartChildProcess(int xlop)
ereport(LOG,
(errmsg("could not fork background writer process: %m")));
break;
case BS_XLOG_AUTOVAC:
ereport(LOG,
(errmsg("could not fork auto vacuum process: %m")));
break;
default:
ereport(LOG,
(errmsg("could not fork process: %m")));
@@ -3395,24 +3294,6 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
return true;
}
/*
* This should be used only for reporting "interactive" errors (essentially,
* bogus arguments on the command line). Once the postmaster is launched,
* use ereport. In particular, don't use this for anything that occurs
* after pmdaemonize.
*/
static void
postmaster_error(const char *fmt,...)
{
va_list ap;
fprintf(stderr, "%s: ", progname);
va_start(ap, fmt);
vfprintf(stderr, gettext(fmt), ap);
va_end(ap);
fprintf(stderr, "\n");
}
#ifdef EXEC_BACKEND
@@ -3852,7 +3733,7 @@ win32_sigchld_waiter(LPVOID param)
if (r == WAIT_OBJECT_0)
pg_queue_signal(SIGCHLD);
else
fprintf(stderr, "ERROR: failed to wait on child process handle: %d\n",
write_stderr("ERROR: failed to wait on child process handle: %d\n",
(int) GetLastError());
CloseHandle(procHandle);
return 0;

View File

@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.222 2004/07/21 20:23:01 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.223 2004/07/21 20:34:46 momjian Exp $
*
*--------------------------------------------------------------------
*/
@@ -43,9 +43,7 @@
#include "optimizer/prep.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
#include "pgstat.h"
#include "postmaster/bgwriter.h"
#include "postmaster/pg_autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/bufmgr.h"
#include "storage/fd.h"
@@ -57,6 +55,7 @@
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "pgstat.h"
char *guc_pgdata;
char *guc_hbafile;
@@ -643,14 +642,6 @@ static struct config_bool ConfigureNamesBool[] =
&pgstat_collect_blocklevel,
false, NULL, NULL
},
{
{"autovacuum", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Starts the auto vacuum subprocess."),
NULL
},
&autovacuum_start_daemon,
false, NULL, NULL
},
{
{"trace_notify", PGC_USERSET, DEVELOPER_OPTIONS,
@@ -1293,30 +1284,6 @@ static struct config_int ConfigureNamesInt[] =
&block_size,
BLCKSZ, BLCKSZ, BLCKSZ, NULL, NULL
},
{
{"autovacuum_vacuum_threshold_base", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Minimum number of tuple updates or deletes prior to vacuum."),
NULL
},
&autovacuum_vacuum_base,
1000, 0, INT_MAX, NULL, NULL
},
{
{"autovacuum_analyze_threshold_base", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Minimum number of tuple updates or deletes prior to analyze."),
NULL
},
&autovacuum_analyze_base,
500, 0, INT_MAX, NULL, NULL
},
{
{"autovacuum_naptime", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Minimum number of tuple updates or deletes prior to analyze."),
NULL
},
&autovacuum_analyze_base,
500, 0, INT_MAX, NULL, NULL
},
/* End-of-list marker */
{
@@ -1397,22 +1364,6 @@ static struct config_real ConfigureNamesReal[] =
&phony_random_seed,
0.5, 0.0, 1.0, assign_random_seed, show_random_seed
},
{
{"autovacuum_vacuum_threshold_sf", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Numer of tuple updates or deletes prior to vacuum as a factor of reltuples."),
NULL
},
&autovacuum_vacuum_scaling_factor,
2, 0, 100, NULL, NULL
},
{
{"autovacuum_analyze_threshold_sf", PGC_SIGHUP, AUTOVACUUM,
gettext_noop("Numer of tuple updates or deletes prior to analyze as a factor of reltuples."),
NULL
},
&autovacuum_analyze_scaling_factor,
1, 0, 100, NULL, NULL
},
/* End-of-list marker */
{

View File

@@ -237,16 +237,6 @@
#stats_reset_on_server_start = true
#---------------------------------------------------------------------------
# VACUUM DAEMON
#---------------------------------------------------------------------------
#autovacuum = false # requires stats_row_level = true
#autovacuum_vacuum_threshold_base = 1000
#autovacuum_vacuum_threshold_sf = 2
#autovacuum_analyze_threshold_base = 500
#autovacuum_analyze_threshold_sf = 1
#---------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#---------------------------------------------------------------------------