Skip to content

Commit

Permalink
Now that we have forced slon to select with an index scan from the
Browse files Browse the repository at this point in the history
log tables, we can lower the cleanup and vacuum frequencies.

Jan
  • Loading branch information
Jan Wieck authored and Jan Wieck committed Jun 28, 2004
1 parent 47e8588 commit 5aac9b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
37 changes: 21 additions & 16 deletions src/slon/cleanup_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
*-------------------------------------------------------------------------
*/

Expand All @@ -28,7 +28,6 @@
#include "slon.h"



/* ----------
* cleanupThread_main
*
Expand All @@ -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");

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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));
}

/*
Expand Down
7 changes: 6 additions & 1 deletion src/slon/slon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 $
*-------------------------------------------------------------------------
*/

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5aac9b0

Please sign in to comment.