diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-11 21:11:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-11 21:11:50 +0000 |
commit | d90c531188196cd4ea6683c7f4395151b42028a2 (patch) | |
tree | aef955843c8a9648f7841d0e934ed152976129fa /src/backend/utils/init/postinit.c | |
parent | f6c30d54fa26047cc2e7315debb85a0a20a07c90 (diff) | |
download | postgresql-d90c531188196cd4ea6683c7f4395151b42028a2.tar.gz postgresql-d90c531188196cd4ea6683c7f4395151b42028a2.zip |
Autovacuum loose end mop-up. Provide autovacuum-specific vacuum cost
delay and limit, both as global GUCs and as table-specific entries in
pg_autovacuum. stats_reset_on_server_start is now OFF by default,
but a reset is forced if we did WAL replay. XID-wrap vacuums do not
ANALYZE, but do FREEZE if it's a template database. Alvaro Herrera
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r-- | src/backend/utils/init/postinit.c | 53 |
1 files changed, 27 insertions, 26 deletions
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 |