Thread: BUG #3326: Invalid lower bound of autovacuum_cost_limit

BUG #3326: Invalid lower bound of autovacuum_cost_limit

From
"Galy Lee"
Date:
The following bug has been logged online:

Bug reference:      3326
Logged by:          Galy Lee
Email address:      lee.galy@oss.ntt.co.jp
PostgreSQL version: 8.3
Operating system:   Red Hat 4.
Description:        Invalid lower bound of autovacuum_cost_limit
Details:

Hello

I found some bugs which relative to the autovacuum_cost_limit GUC
parameter.

* Bug-1:  Invalid lower bound of autovacuum_cost_limit

autovacuum_vacuum_cost_limit should be the following value:
  autovacuum_vacuum_cost_limit = -1, or [1, 10000]
  (0 should be prohibited. )

But 0 can also be accepted for autovacuum_vacuum_cost_limit now.

This causes zero-division error for autovacuum:

   ERROR:  floating-point exception
   DETAIL:  An invalid floating-point operation was signaled. This
   probably means an out-of-range result or an invalid operation,
   such as division by zero.

* Bug-2: 0-cost-limit for autovacuum worker

When autovacuum_max_workers > autovacuum_vacuum_cost_limit, the above
zero-division error also happened.

* Bug-3: no GUC constrain check for pg_autovacuum

The settings in pg_autovacuum are not checked enough now. Invalid value
can be passed to autovacuum, this also causes some columns in
pg_autovacuum has inconsistent upper and lower bound with their original
GUC constrain.

 pg_autovacuum colum | definition |  GUC constrain
 --------------------+------------+--------------------------
 vac_base_thresh     | integer    |  [0, INT_MAX]
 vac_scale_factor    | real       |  [0.0, 100.0]
 anl_base_thresh     | integer    |  [0, INT_MAX]
 anl_scale_factor    | real       |  [0.0, 100.0]
 vac_cost_delay      | integer    |  [-1, 1000]
 vac_cost_limit      | integer    |  [-1, 10000]
 freeze_min_age      | integer    |  [0, 1000000000]
 freeze_max_age      | integer    |  [100000000, 2000000000]

The above table shows the wrong mapping between pg_autovacuum columns
and GUC constrain.

Re: BUG #3326: Invalid lower bound of autovacuum_cost_limit

From
Alvaro Herrera
Date:
Galy Lee wrote:

Hi Galy,

> The following bug has been logged online:
>
> Bug reference:      3326
> Logged by:          Galy Lee
> Email address:      lee.galy@oss.ntt.co.jp
> PostgreSQL version: 8.3
> Operating system:   Red Hat 4.
> Description:        Invalid lower bound of autovacuum_cost_limit
> Details:

Damn.  Thanks for reporting -- I'll investigate these issues.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: BUG #3326: Invalid lower bound of autovacuum_cost_limit

From
Alvaro Herrera
Date:
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.

Attachment