CVS User Account cvsuser
Mon Aug 30 16:47:48 PDT 2004
Log Message:
-----------
Add -c directive to change the frequency of vaccums, 0 disables to allow pg_autovac to deal with it

Modified Files:
--------------
    slony1-engine/src/slon:
        cleanup_thread.c (r1.15 -> r1.16)
        slon.c (r1.27 -> r1.28)
        slon.h (r1.36 -> r1.37)

-------------- next part --------------
Index: slon.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lsrc/slon/slon.c -Lsrc/slon/slon.c -u -w -r1.27 -r1.28
--- src/slon/slon.c
+++ src/slon/slon.c
@@ -72,7 +72,8 @@
 	extern char *optarg;
 	int			group_size_set = 0;
 
-	while ((c = getopt(argc, argv, "d:s:t:g:h")) != EOF)
+
+	while ((c = getopt(argc, argv, "d:s:t:g:c:h")) != EOF)
 	{
 		switch(c)
 		{
@@ -119,6 +120,14 @@
 						group_size_set = 1;
 						break;
 
+			case 'c':	vac_frequency = strtol(optarg, NULL, 10);
+						if (vac_frequency < 0 || vac_frequency > 10)
+						{
+							fprintf(stderr, "Vaccum frequency must be between 0 (disable) and 10\n");
+							errors++;
+						}
+						break;
+
 			case 'h':	errors++;
 						break;
 
@@ -140,6 +149,7 @@
 		fprintf(stderr, "    -s <milliseconds>     SYNC check interval (default 10000)\n");
 		fprintf(stderr, "    -t <milliseconds>     SYNC interval timeout (default 60000)\n");
 		fprintf(stderr, "    -g <num>              maximum SYNC group size (default 6)\n");
+		fprintf(stderr, "    -c <num>		   how often to vaccum in cleanup cycles\n");
 		return 1;
 	}
 
Index: slon.h
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -Lsrc/slon/slon.h -Lsrc/slon/slon.h -u -w -r1.36 -r1.37
--- src/slon/slon.h
+++ src/slon/slon.h
@@ -387,6 +387,13 @@
  */
 extern void	   *slon_localEventThread(void *dummy);
 
+/*
+ * ----------
+ * Global variables in cleanup_thread.c
+ * ----------
+ */
+
+extern int		vac_frequency;
 
 /* ----------
  * Functions in cleanup_thread.c
@@ -485,7 +492,6 @@
  */
 extern int		slon_log_level;
 
-
 /* ----------
  * Functions in misc.c
  * ----------
Index: cleanup_thread.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/cleanup_thread.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lsrc/slon/cleanup_thread.c -Lsrc/slon/cleanup_thread.c -u -w -r1.15 -r1.16
--- src/slon/cleanup_thread.c
+++ src/slon/cleanup_thread.c
@@ -29,6 +29,12 @@
 
 
 /* ----------
+ * Global data
+ * ----------
+ */
+int		vac_frequency = SLON_VACUUM_FREQUENCY;
+
+/* ----------
  * cleanupThread_main
  *
  *	Periodically calls the stored procedure to remove old events
@@ -72,26 +78,6 @@
 	dstring_init(&query2);
 
 	/*
-	 * Build the query string for vacuuming replication
-	 * runtime data and event tables
-	 */
-	dstring_init(&query3);
-	slon_mkquery(&query3, 
-			"vacuum analyze %s.sl_event; "
-			"vacuum analyze %s.sl_confirm; "
-			"vacuum analyze %s.sl_setsync; "
-			"vacuum analyze %s.sl_log_1; "
-			"vacuum analyze %s.sl_log_2;"
-			"vacuum analyze %s.sl_seqlog;"
-			"vacuum analyze pg_catalog.pg_listener;",
-			rtcfg_namespace, 
-			rtcfg_namespace, 
-			rtcfg_namespace, 
-			rtcfg_namespace, 
-			rtcfg_namespace, 
-			rtcfg_namespace);
-
-	/*
 	 * Loop until shutdown time arrived
 	 */
 	while (sched_wait_time(conn, SCHED_WAIT_SOCK_READ, SLON_CLEANUP_SLEEP * 1000) == SCHED_STATUS_OK)
@@ -180,9 +166,29 @@
 		/*
 		 * Detain the usual suspects (vacuum event and log data)
 		 */
-		if (++vac_count >= SLON_VACUUM_FREQUENCY)
+		if (vac_frequency != 0 && ++vac_count >= vac_frequency)
 		{
 			vac_count = 0;
+			/*
+			 * Build the query string for vacuuming replication
+         		 * runtime data and event tables
+         		*/
+        		dstring_init(&query3);
+        		slon_mkquery(&query3, 
+                        	"vacuum analyze %s.sl_event; "
+                        	"vacuum analyze %s.sl_confirm; "
+                        	"vacuum analyze %s.sl_setsync; "
+                        	"vacuum analyze %s.sl_log_1; "
+                        	"vacuum analyze %s.sl_log_2;"
+                        	"vacuum analyze %s.sl_seqlog;"
+                        	"vacuum analyze pg_catalog.pg_listener;",
+                        	rtcfg_namespace,
+                        	rtcfg_namespace,
+                        	rtcfg_namespace,
+                        	rtcfg_namespace,
+                        	rtcfg_namespace,
+                        	rtcfg_namespace);
+
 
 			gettimeofday(&tv_start, NULL);
 			res = PQexec(dbconn, dstring_data(&query3));
@@ -200,6 +206,11 @@
 			slon_log(SLON_DEBUG2,
 					"cleanupThread: %8.3f seconds for vacuuming\n",
 					TIMEVAL_DIFF(&tv_start, &tv_end));
+			/*
+			 * Free Resources
+			 */
+			dstring_free(&query3);
+
 		}
 	}
 
@@ -208,7 +219,6 @@
 	 */
 	dstring_free(&query1);
 	dstring_free(&query2);
-	dstring_free(&query3);
 
 	/*
 	 * Disconnect from the database


More information about the Slony1-commit mailing list