Galy Lee wrote: > * Bug-2: 0-cost-limit for autovacuum worker > > When autovacuum_max_workers > autovacuum_vacuum_cost_limit, the above > zero-division error also happened.
Ah, this is a problem in the balance code -- it fails to consider that the cost limit may be end up being 0 in the integer calculations. This patch fixes this problem. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/postmaster/autovacuum.c =================================================================== RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/autovacuum.c,v retrieving revision 1.47 diff -c -p -r1.47 autovacuum.c *** src/backend/postmaster/autovacuum.c 30 May 2007 20:11:57 -0000 1.47 --- src/backend/postmaster/autovacuum.c 8 Jun 2007 14:58:19 -0000 *************** autovac_balance_cost(void) *** 1595,1601 **** int limit = (int) (cost_avail * worker->wi_cost_limit_base / cost_total); ! worker->wi_cost_limit = Min(limit, worker->wi_cost_limit_base); elog(DEBUG2, "autovac_balance_cost(pid=%u db=%u, rel=%u, cost_limit=%d, cost_delay=%d)", worker->wi_workerpid, worker->wi_dboid, --- 1595,1605 ---- int limit = (int) (cost_avail * worker->wi_cost_limit_base / cost_total); ! /* ! * We put a lower bound of 1 to the cost_limit, to avoid division- ! * by-zero in the vacuum code. ! */ ! worker->wi_cost_limit = Max(Min(limit, worker->wi_cost_limit_base), 1); elog(DEBUG2, "autovac_balance_cost(pid=%u db=%u, rel=%u, cost_limit=%d, cost_delay=%d)", worker->wi_workerpid, worker->wi_dboid,
---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly