summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAlvaro Herrera2007-02-15 23:23:23 +0000
committerAlvaro Herrera2007-02-15 23:23:23 +0000
commit182065093420b667a850828c3241ffe940df1aa4 (patch)
tree14a1fa8acdaf45cdc11e760e961bd4f91b1c20c4 /src/include
parenteecbb33267642a2f6fcb2a2652f55412b333f4df (diff)
Restructure autovacuum in two processes: a dummy process, which runs
continuously, and requests vacuum runs of "autovacuum workers" to postmaster. The workers do the actual vacuum work. This allows for future improvements, like allowing multiple autovacuum jobs running in parallel. For now, the code keeps the original behavior of having a single autovac process at any time by sleeping until the previous worker has finished.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/miscadmin.h5
-rw-r--r--src/include/postmaster/autovacuum.h19
-rw-r--r--src/include/storage/lwlock.h4
-rw-r--r--src/include/storage/pmsignal.h5
-rw-r--r--src/include/storage/proc.h4
5 files changed, 24 insertions, 13 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 88595112f57..29a450cab60 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.191 2007/01/05 22:19:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.192 2007/02/15 23:23:23 alvherre Exp $
*
* NOTES
* some of the information in this file should be moved to other files.
@@ -302,7 +302,8 @@ extern ProcessingMode Mode;
*****************************************************************************/
/* in utils/init/postinit.c */
-extern bool InitPostgres(const char *dbname, const char *username);
+extern bool InitPostgres(const char *in_dbname, Oid dboid, const char *username,
+ char **out_dbname);
extern void BaseInit(void);
/* in utils/init/miscinit.c */
diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 7b3ad7e5509..facf9de52b2 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.7 2007/01/16 13:28:57 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.8 2007/02/15 23:23:23 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,16 +27,23 @@ extern int autovacuum_vac_cost_limit;
/* Status inquiry functions */
extern bool AutoVacuumingActive(void);
-extern bool IsAutoVacuumProcess(void);
+extern bool IsAutoVacuumLauncherProcess(void);
+extern bool IsAutoVacuumWorkerProcess(void);
/* Functions to start autovacuum process, called from postmaster */
extern void autovac_init(void);
-extern int autovac_start(void);
-extern void autovac_stopped(void);
+extern int StartAutoVacLauncher(void);
+extern int StartAutoVacWorker(void);
#ifdef EXEC_BACKEND
-extern void AutoVacMain(int argc, char *argv[]);
-extern void AutovacuumIAm(void);
+extern void AutoVacLauncherMain(int argc, char *argv[]);
+extern void AutoVacWorkerMain(int argc, char *argv[]);
+extern void AutovacuumWorkerIAm(void);
+extern void AutovacuumLauncherIAm(void);
#endif
+/* shared memory stuff */
+extern Size AutoVacuumShmemSize(void);
+extern void AutoVacuumShmemInit(void);
+
#endif /* AUTOVACUUM_H */
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index cff28815d9d..b4503f92135 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.33 2007/01/05 22:19:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.34 2007/02/15 23:23:23 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,8 @@ typedef enum LWLockId
TablespaceCreateLock,
BtreeVacuumLock,
AddinShmemInitLock,
+ AutovacuumLock,
+ /* Individual lock IDs end here */
FirstBufMappingLock,
FirstLockMgrLock = FirstBufMappingLock + NUM_BUFFER_PARTITIONS,
diff --git a/src/include/storage/pmsignal.h b/src/include/storage/pmsignal.h
index bc705fc1362..8142ee0f2c4 100644
--- a/src/include/storage/pmsignal.h
+++ b/src/include/storage/pmsignal.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/pmsignal.h,v 1.16 2007/01/05 22:19:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/pmsignal.h,v 1.17 2007/02/15 23:23:23 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,7 +26,8 @@ typedef enum
PMSIGNAL_WAKEN_CHILDREN, /* send a SIGUSR1 signal to all backends */
PMSIGNAL_WAKEN_ARCHIVER, /* send a NOTIFY signal to xlog archiver */
PMSIGNAL_ROTATE_LOGFILE, /* send SIGUSR1 to syslogger to rotate logfile */
- PMSIGNAL_START_AUTOVAC, /* start an autovacuum iteration */
+ PMSIGNAL_START_AUTOVAC_LAUNCHER, /* start an autovacuum launcher */
+ PMSIGNAL_START_AUTOVAC_WORKER, /* start an autovacuum worker */
NUM_PMSIGNALS /* Must be last value of enum! */
} PMSignalReason;
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index b86f210fbe8..3e296fb0a3a 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.93 2007/01/16 13:28:57 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.94 2007/02/15 23:23:23 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,7 +121,7 @@ typedef struct PROC_HDR
* We set aside some extra PGPROC structures for "dummy" processes,
* ie things that aren't full-fledged backends but need shmem access.
*/
-#define NUM_DUMMY_PROCS 2
+#define NUM_DUMMY_PROCS 3
/* configurable options */