Permalink
Browse files

Now that we have forced slon to select with an index scan from the

log tables, we can lower the cleanup and vacuum frequencies.

Jan
  • Loading branch information...
1 parent 47e8588 commit 5aac9b08e77670cb8c252ebf44dc1f0466c8cb3c Jan Wieck committed Jun 28, 2004
Showing with 27 additions and 17 deletions.
  1. +21 −16 src/slon/cleanup_thread.c
  2. +6 −1 src/slon/slon.h
View
@@ -6,7 +6,7 @@
* Copyright (c) 2003-2004, PostgreSQL Global Development Group
* Author: Jan Wieck, Afilias USA INC.
*
- * $Id: cleanup_thread.c,v 1.12 2004-06-23 23:29:43 wieck Exp $
+ * $Id: cleanup_thread.c,v 1.13 2004-06-28 15:44:07 wieck Exp $
*-------------------------------------------------------------------------
*/
@@ -28,7 +28,6 @@
#include "slon.h"
-
/* ----------
* cleanupThread_main
*
@@ -50,6 +49,7 @@ cleanupThread_main(void *dummy)
struct timeval tv_start;
struct timeval tv_end;
int n, t;
+ int vac_count = 0;
slon_log(SLON_DEBUG1, "cleanupThread: thread starts\n");
@@ -93,7 +93,7 @@ cleanupThread_main(void *dummy)
/*
* Loop until shutdown time arrived
*/
- while (sched_wait_time(conn, SCHED_WAIT_SOCK_READ, 300000) == SCHED_STATUS_OK)
+ while (sched_wait_time(conn, SCHED_WAIT_SOCK_READ, SLON_CLEANUP_SLEEP * 1000) == SCHED_STATUS_OK)
{
/*
* Call the stored procedure cleanupEvent()
@@ -179,22 +179,27 @@ cleanupThread_main(void *dummy)
/*
* Detain the usual suspects (vacuum event and log data)
*/
- gettimeofday(&tv_start, NULL);
- res = PQexec(dbconn, dstring_data(&query3));
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ if (++vac_count >= SLON_VACUUM_FREQUENCY)
{
- slon_log(SLON_FATAL,
- "cleanupThread: \"%s\" - %s",
- dstring_data(&query3), PQresultErrorMessage(res));
+ vac_count = 0;
+
+ gettimeofday(&tv_start, NULL);
+ res = PQexec(dbconn, dstring_data(&query3));
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ slon_log(SLON_FATAL,
+ "cleanupThread: \"%s\" - %s",
+ dstring_data(&query3), PQresultErrorMessage(res));
+ PQclear(res);
+ slon_abort();
+ break;
+ }
PQclear(res);
- slon_abort();
- break;
+ gettimeofday(&tv_end, NULL);
+ slon_log(SLON_DEBUG2,
+ "cleanupThread: %8.3f seconds for vacuuming\n",
+ TIMEVAL_DIFF(&tv_start, &tv_end));
}
- PQclear(res);
- gettimeofday(&tv_end, NULL);
- slon_log(SLON_DEBUG2,
- "cleanupThread: %8.3f seconds for vacuuming\n",
- TIMEVAL_DIFF(&tv_start, &tv_end));
}
/*
View
@@ -6,7 +6,7 @@
* Copyright (c) 2003-2004, PostgreSQL Global Development Group
* Author: Jan Wieck, Afilias USA INC.
*
- * $Id: slon.h,v 1.34 2004-06-21 21:42:56 wieck Exp $
+ * $Id: slon.h,v 1.35 2004-06-28 15:44:07 wieck Exp $
*-------------------------------------------------------------------------
*/
@@ -38,6 +38,11 @@
#endif
+#define SLON_CLEANUP_SLEEP 600 /* sleep 10 minutes between */
+ /* cleanup calls */
+#define SLON_VACUUM_FREQUENCY 3 /* vacuum every 3rd cleanup */
+
+
typedef enum {
SLON_TSTAT_NONE,
SLON_TSTAT_RUNNING,

0 comments on commit 5aac9b0

Please sign in to comment.