Re: pgsql: Allow vacuum command to process indexes in parallel. - Mailing list pgsql-committers

From Amit Kapila
Subject Re: pgsql: Allow vacuum command to process indexes in parallel.
Date
Msg-id CAA4eK1KPex3S+2VX=ChFzSTRoBR+DjfGCUvFobYCPiK5BjQ2VA@mail.gmail.com
Whole thread Raw
In response to Re: pgsql: Allow vacuum command to process indexes in parallel.  (Mahendra Singh Thalor <mahi6run@gmail.com>)
Responses Re: pgsql: Allow vacuum command to process indexes in parallel.
List pgsql-committers
On Mon, Mar 30, 2020 at 8:30 AM Mahendra Singh Thalor
<mahi6run@gmail.com> wrote:
>
> > > > 2077          if ((shared_balance >= VacuumCostLimit) &&
> > > > >>>     CID ...:  Incorrect expression  (UNINTENDED_INTEGER_DIVISION)
> > > > >>>     Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient
totype "double". Any remainder, or fractional part of the quotient, is ignored.
 
> > > > 2078                  (VacuumCostBalanceLocal > 0.5 * (VacuumCostLimit / nworkers)))
> > > > 2079          {
> > > > 2080                  /* Compute sleep time based on the local cost balance */
> > > > 2081                  msec = VacuumCostDelay * VacuumCostBalanceLocal / VacuumCostLimit;
> > > > 2082                  pg_atomic_sub_fetch_u32(VacuumSharedCostBalance, VacuumCostBalanceLocal);
> > > > 2083                  VacuumCostBalanceLocal = 0;
> > >
> > > Which seems like a fair enough complaint?
> > >
> >
> > I'll look into it.
> >
>
> Hi,
> Attaching patch to fix this but I don't have coverity setup so I
> haven't verified fix.
>

- (VacuumCostBalanceLocal > 0.5 * (VacuumCostLimit / nworkers)))
+ (VacuumCostBalanceLocal > (int) (0.5 * ((double) VacuumCostLimit /
nworkers))))
  {

I think typecasting to double should be enough to fix this coverity error.

-- 
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: Re: pgsql: Allow vacuum command to process indexes in parallel.
Next
From: Magnus Hagander
Date:
Subject: pgsql: Fix assorted typos