Re: Problems with autovacuum

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

 



Tom Lane escribió:

> Bingo, that's surely exactly what was happening to the OP.  He had 2000
> databases and naptime at (I assume) the default; so he was rerunning
> rebuild_database_list every 100ms.
> 
> So that recovery code path needs some more thought.  Maybe a lower bound
> on how often to do rebuild_database_list?  And/or don't set adl_next_worker
> to less than 100ms in the future to begin with?

I've been giving this some thought and tried several approaches.  In the
end the one that I like the most is raising autovacuum_naptime to a
reasonable value for the exiting number of databases.  The only problem
I have with it is that it's trivial to change it in the autovacuum
launcher process and have it stick, but there's no way to propagate the
value out to backends or postmaster to that they SHOW the actual value
in use by the launcher.  The best I can do is emit a WARNING with the
new value.

I have experimented with other choices such as not rebuilding the
database list if the time elapsed since last rebuild is not very long,
but there were small problems with that so I'd prefer to avoid it.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
*** src/backend/postmaster/autovacuum.c	12 Nov 2008 10:10:43 -0000	1.71.2.7
--- src/backend/postmaster/autovacuum.c	8 Jun 2009 19:28:12 -0000
***************
*** 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();
  
  		/*
--- 991,1013 ----
  		/* sort the array */
  		qsort(dbary, nelems, sizeof(avl_dbase), db_comparator);
  
! 		/*
! 		 * Determine the time interval between databases in the schedule.
! 		 * Here we can determine an minimum for the naptime; if we see that
! 		 * the configured naptime would take us to sleep times lower than 100ms
! 		 * (which launcher_determine_sleep is hardcoded not to allow), set
! 		 * the naptime to the required naptime plus some headroom.
! 		 */
  		millis_increment = 1000.0 * autovacuum_naptime / nelems;
+ 		if (millis_increment < 100.0)
+ 		{
+ 			autovacuum_naptime = nelems * 0.11;
+ 			millis_increment = 1000.0 * autovacuum_naptime / nelems;
+ 			ereport(WARNING,
+ 					(errmsg("autovacuum_naptime has been raised to %d due to high number of databases",
+ 							autovacuum_naptime)));
+ 		}
+ 
  		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