Re: Problems with autovacuum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tom Lane escribió:

> Well, that code isn't even correct I think; you're not supposed to
> modify a GUC variable directly.  I think you should just silently
> use a naptime of at least X without changing the nominal GUC variable.
> And definitely without the WARNING --- that's nothing but log spam.

Glitches fixed in this version; will apply shortly to 8.3 and HEAD.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/backend/postmaster/autovacuum.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/autovacuum.c,v
retrieving revision 1.71.2.7
diff -c -p -r1.71.2.7 autovacuum.c
*** src/backend/postmaster/autovacuum.c	12 Nov 2008 10:10:43 -0000	1.71.2.7
--- src/backend/postmaster/autovacuum.c	9 Jun 2009 15:46:22 -0000
*************** int			Log_autovacuum_min_duration = -1;
*** 119,124 ****
--- 119,126 ----
  /* how long to keep pgstat data in the launcher, in milliseconds */
  #define STATS_READ_DELAY 1000
  
+ /* the minimum allowed time between two awakening of the launcher */
+ #define MIN_AUTOVAC_SLEEPTIME 100.0 /* milliseconds */
  
  /* Flags to tell if we are in an autovacuum process */
  static bool am_autovacuum_launcher = false;
*************** launcher_determine_sleep(bool canlaunch,
*** 816,826 ****
  		return;
  	}
  
! 	/* 100ms is the smallest time we'll allow the launcher to sleep */
! 	if (nap->tv_sec <= 0 && nap->tv_usec <= 100000)
  	{
  		nap->tv_sec = 0;
! 		nap->tv_usec = 100000;	/* 100 ms */
  	}
  }
  
--- 818,828 ----
  		return;
  	}
  
! 	/* The smallest time we'll allow the launcher to sleep. */
! 	if (nap->tv_sec <= 0 && nap->tv_usec <= MIN_AUTOVAC_SLEEPTIME * 1000)
  	{
  		nap->tv_sec = 0;
! 		nap->tv_usec = MIN_AUTOVAC_SLEEPTIME * 1000;
  	}
  }
  
*************** rebuild_database_list(Oid newdb)
*** 991,998 ****
  		/* sort the array */
  		qsort(dbary, nelems, sizeof(avl_dbase), db_comparator);
  
! 		/* this is the time interval between databases in the schedule */
  		millis_increment = 1000.0 * autovacuum_naptime / nelems;
  		current_time = GetCurrentTimestamp();
  
  		/*
--- 993,1009 ----
  		/* sort the array */
  		qsort(dbary, nelems, sizeof(avl_dbase), db_comparator);
  
! 		/*
! 		 * Determine the time interval between databases in the schedule.
! 		 * If we see that the configured naptime would take us to sleep times
! 		 * lower than our min sleep time (which launcher_determine_sleep is
! 		 * coded not to allow), silently use a larger naptime (but don't touch
! 		 * the GUC variable).
! 		 */
  		millis_increment = 1000.0 * autovacuum_naptime / nelems;
+ 		if (millis_increment <= MIN_AUTOVAC_SLEEPTIME)
+ 			millis_increment = MIN_AUTOVAC_SLEEPTIME * 1.1;
+ 
  		current_time = GetCurrentTimestamp();
  
  		/*
-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux