diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/init/flatfiles.c | 21 | ||||
-rw-r--r-- | src/backend/utils/init/postinit.c | 53 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 22 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 6 |
4 files changed, 65 insertions, 37 deletions
diff --git a/src/backend/utils/init/flatfiles.c b/src/backend/utils/init/flatfiles.c index 7087a9887d4..7d9d2e6cb25 100644 --- a/src/backend/utils/init/flatfiles.c +++ b/src/backend/utils/init/flatfiles.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.13 2005/07/28 22:27:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.14 2005/08/11 21:11:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -208,12 +208,14 @@ write_database_file(Relation drel) char *datname; Oid datoid; Oid dattablespace; - TransactionId datfrozenxid; + TransactionId datfrozenxid, + datvacuumxid; datname = NameStr(dbform->datname); datoid = HeapTupleGetOid(tuple); dattablespace = dbform->dattablespace; datfrozenxid = dbform->datfrozenxid; + datvacuumxid = dbform->datvacuumxid; /* * Identify the oldest datfrozenxid, ignoring databases that are not @@ -242,13 +244,14 @@ write_database_file(Relation drel) } /* - * The file format is: "dbname" oid tablespace frozenxid + * The file format is: "dbname" oid tablespace frozenxid vacuumxid * - * The xid is not needed for backend startup, but may be of use - * for forensic purposes. + * The xids are not needed for backend startup, but are of use to + * autovacuum, and might also be helpful for forensic purposes. */ fputs_quote(datname, fp); - fprintf(fp, " %u %u %u\n", datoid, dattablespace, datfrozenxid); + fprintf(fp, " %u %u %u %u\n", + datoid, dattablespace, datfrozenxid, datvacuumxid); } heap_endscan(scan); @@ -654,8 +657,10 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) * base backup which may be far out of sync with the current state. * * In theory we could skip rebuilding the flat files if no WAL replay - * occurred, but it seems safest to just do it always. We have to - * scan pg_database to compute the XID wrap limit anyway. + * occurred, but it seems best to just do it always. We have to + * scan pg_database to compute the XID wrap limit anyway. Also, this + * policy means we need not force initdb to change the format of the + * flat files. * * In a standalone backend we pass database_only = true to skip processing * the auth file. We won't need it, and building it could fail if there's diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 058872a73f2..73fedbdd477 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.156 2005/08/08 03:12:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.157 2005/08/11 21:11:46 tgl Exp $ * * *------------------------------------------------------------------------- @@ -20,8 +20,10 @@ #include <math.h> #include <unistd.h> +#include "access/genam.h" #include "access/heapam.h" #include "catalog/catalog.h" +#include "catalog/indexing.h" #include "catalog/namespace.h" #include "catalog/pg_authid.h" #include "catalog/pg_database.h" @@ -79,7 +81,7 @@ FindMyDatabase(const char *name, Oid *db_id, Oid *db_tablespace) char *filename; FILE *db_file; char thisname[NAMEDATALEN]; - TransactionId frozenxid; + TransactionId dummyxid; filename = database_getflatfilename(); db_file = AllocateFile(filename, "r"); @@ -89,7 +91,8 @@ FindMyDatabase(const char *name, Oid *db_id, Oid *db_tablespace) errmsg("could not open file \"%s\": %m", filename))); while (read_pg_database_line(db_file, thisname, db_id, - db_tablespace, &frozenxid)) + db_tablespace, &dummyxid, + &dummyxid)) { if (strcmp(thisname, name) == 0) { @@ -131,7 +134,7 @@ static void ReverifyMyDatabase(const char *name) { Relation pgdbrel; - HeapScanDesc pgdbscan; + SysScanDesc pgdbscan; ScanKeyData key; HeapTuple tup; Form_pg_database dbform; @@ -147,9 +150,10 @@ ReverifyMyDatabase(const char *name) BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(name)); - pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key); + pgdbscan = systable_beginscan(pgdbrel, DatabaseNameIndexId, true, + SnapshotNow, 1, &key); - tup = heap_getnext(pgdbscan, ForwardScanDirection); + tup = systable_getnext(pgdbscan); if (!HeapTupleIsValid(tup) || HeapTupleGetOid(tup) != MyDatabaseId) { @@ -238,7 +242,7 @@ ReverifyMyDatabase(const char *name) } } - heap_endscan(pgdbscan); + systable_endscan(pgdbscan); heap_close(pgdbrel, RowShareLock); } @@ -428,6 +432,18 @@ InitPostgres(const char *dbname, const char *username) /* Initialize portal manager */ EnablePortalManager(); + /* + * Set up process-exit callback to do pre-shutdown cleanup. This + * has to be after we've initialized all the low-level modules + * like the buffer manager, because during shutdown this has to + * run before the low-level modules start to close down. On the + * other hand, we want it in place before we begin our first + * transaction --- if we fail during the initialization transaction, + * as is entirely possible, we need the AbortTransaction call to + * clean up. + */ + on_shmem_exit(ShutdownPostgres, 0); + /* start a new transaction here before access to db */ if (!bootstrap) StartTransactionCommand(); @@ -465,7 +481,8 @@ InitPostgres(const char *dbname, const char *username) /* * Unless we are bootstrapping, double-check that InitMyDatabaseInfo() * got a correct result. We can't do this until all the - * database-access infrastructure is up. + * database-access infrastructure is up. (Also, it wants to know if + * the user is a superuser, so the above stuff has to happen first.) */ if (!bootstrap) ReverifyMyDatabase(dbname); @@ -509,24 +526,10 @@ InitPostgres(const char *dbname, const char *username) /* initialize client encoding */ InitializeClientEncoding(); - /* - * Initialize statistics collection for this backend. We do this - * here because the shutdown hook it sets up needs to be invoked - * at the corresponding phase of backend shutdown: after - * ShutdownPostgres and before we drop access to shared memory. - */ + /* initialize statistics collection for this backend */ if (IsUnderPostmaster) pgstat_bestart(); - /* - * Set up process-exit callback to do pre-shutdown cleanup. This - * should be last because we want shmem_exit to call this routine - * before the exit callbacks that are registered by buffer manager, - * lock manager, etc. We need to run this code before we close down - * database access! - */ - on_shmem_exit(ShutdownPostgres, 0); - /* close the transaction we started above */ if (!bootstrap) CommitTransactionCommand(); @@ -538,9 +541,7 @@ InitPostgres(const char *dbname, const char *username) /* * Backend-shutdown callback. Do cleanup that we want to be sure happens * before all the supporting modules begin to nail their doors shut via - * their own callbacks. Note that because this has to be registered very - * late in startup, it will not get called if we suffer a failure *during* - * startup. + * their own callbacks. * * User-level cleanup, such as temp-relation removal and UNLISTEN, happens * via separate callbacks that execute before this one. We don't combine the diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f3426b18cab..bb0634463ed 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.280 2005/07/30 15:17:20 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.281 2005/08/11 21:11:47 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -672,7 +672,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &pgstat_collect_resetonpmstart, - true, NULL, NULL + false, NULL, NULL }, { {"stats_command_string", PGC_SUSET, STATS_COLLECTOR, @@ -1161,6 +1161,24 @@ static struct config_int ConfigureNamesInt[] = }, { + {"autovacuum_vacuum_cost_delay", PGC_SIGHUP, AUTOVACUUM, + gettext_noop("Vacuum cost delay in milliseconds, for autovacuum."), + NULL + }, + &autovacuum_vac_cost_delay, + -1, -1, 1000, NULL, NULL + }, + + { + {"autovacuum_vacuum_cost_limit", PGC_SIGHUP, AUTOVACUUM, + gettext_noop("Vacuum cost amount available before napping, for autovacuum."), + NULL + }, + &autovacuum_vac_cost_limit, + -1, -1, 10000, NULL, NULL + }, + + { {"max_files_per_process", PGC_POSTMASTER, RESOURCES_KERNEL, gettext_noop("Sets the maximum number of simultaneously open files for each server process."), NULL diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7eea5513c2b..86f236910f8 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -288,7 +288,7 @@ #stats_command_string = off #stats_block_level = off #stats_row_level = off -#stats_reset_on_server_start = on +#stats_reset_on_server_start = off #--------------------------------------------------------------------------- @@ -301,6 +301,10 @@ #autovacuum_analyze_threshold = 500 # min # of tuple updates before analyze #autovacuum_vacuum_scale_factor = 0.4 # fraction of rel size before vacuum #autovacuum_analyze_scale_factor = 0.2 # fraction of rel size before analyze +#autovacuum_vacuum_cost_delay = -1 # default vacuum cost delay for autovac + # -1 means use vacuum_cost_delay +#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for autovac + # -1 means use vacuum_cost_limit #--------------------------------------------------------------------------- |