pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Allow vacuum command to process indexes in parallel.
10+ messages / 4 participants
[nested] [flat]
Commits from this thread:
2020-04-01 2401d93718 Fix coverity complaint about commit 40d964ec99.
* pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-01-20 02:33 Amit Kapila <akapila@postgresql.org>
0 siblings, 1 reply; 10+ messages in thread
From: Amit Kapila @ 2020-01-20 02:33 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Allow vacuum command to process indexes in parallel.
This feature allows the vacuum to leverage multiple CPUs in order to
process indexes. This enables us to perform index vacuuming and index
cleanup with background workers. This adds a PARALLEL option to VACUUM
command where the user can specify the number of workers that can be used
to perform the command which is limited by the number of indexes on a
table. Specifying zero as a number of workers will disable parallelism.
This option can't be used with the FULL option.
Each index is processed by at most one vacuum process. Therefore parallel
vacuum can be used when the table has at least two indexes.
The parallel degree is either specified by the user or determined based on
the number of indexes that the table has, and further limited by
max_parallel_maintenance_workers. The index can participate in parallel
vacuum iff it's size is greater than min_parallel_index_scan_size.
Author: Masahiko Sawada and Amit Kapila
Reviewed-by: Dilip Kumar, Amit Kapila, Robert Haas, Tomas Vondra,
Mahendra Singh and Sergei Kornilov
Tested-by: Mahendra Singh and Prabhat Sahu
Discussion:
https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.com
https://postgr.es/m/CAA4eK1J-VoR9gzS5E75pcD-OH0mEyCdp8RihcwKrcuw7J-Q0+w@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/40d964ec997f64227bc0ff5e058dc4a5770a70a9
Modified Files
--------------
doc/src/sgml/config.sgml | 18 +-
doc/src/sgml/ref/vacuum.sgml | 61 +-
src/backend/access/heap/vacuumlazy.c | 1256 ++++++++++++++++++++++++++++++---
src/backend/access/transam/parallel.c | 26 +-
src/backend/commands/vacuum.c | 135 +++-
src/backend/postmaster/autovacuum.c | 2 +
src/bin/psql/tab-complete.c | 2 +-
src/include/access/heapam.h | 3 +
src/include/access/parallel.h | 4 +-
src/include/commands/vacuum.h | 12 +
src/test/regress/expected/vacuum.out | 34 +
src/test/regress/sql/vacuum.sql | 31 +
src/tools/pgindent/typedefs.list | 4 +
13 files changed, 1452 insertions(+), 136 deletions(-)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-29 22:48 Andres Freund <andres@anarazel.de>
parent: Amit Kapila <akapila@postgresql.org>
0 siblings, 2 replies; 10+ messages in thread
From: Andres Freund @ 2020-03-29 22:48 UTC (permalink / raw)
To: Amit Kapila <akapila@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org
Hi,
On 2020-01-20 02:33:34 +0000, Amit Kapila wrote:
> Allow vacuum command to process indexes in parallel.
>
> This feature allows the vacuum to leverage multiple CPUs in order to
> process indexes. This enables us to perform index vacuuming and index
> cleanup with background workers. This adds a PARALLEL option to VACUUM
> command where the user can specify the number of workers that can be used
> to perform the command which is limited by the number of indexes on a
> table. Specifying zero as a number of workers will disable parallelism.
> This option can't be used with the FULL option.
>
> Each index is processed by at most one vacuum process. Therefore parallel
> vacuum can be used when the table has at least two indexes.
>
> The parallel degree is either specified by the user or determined based on
> the number of indexes that the table has, and further limited by
> max_parallel_maintenance_workers. The index can participate in parallel
> vacuum iff it's size is greater than min_parallel_index_scan_size.
>
> Author: Masahiko Sawada and Amit Kapila
> Reviewed-by: Dilip Kumar, Amit Kapila, Robert Haas, Tomas Vondra,
> Mahendra Singh and Sergei Kornilov
> Tested-by: Mahendra Singh and Prabhat Sahu
> Discussion:
> https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.com
> https://postgr.es/m/CAA4eK1J-VoR9gzS5E75pcD-OH0mEyCdp8RihcwKrcuw7J-Q0+w@mail.gmail.com
Coverity is complaining that:
> ** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
>
>
> ________________________________________________________________________________________________________
> *** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
> 2072 shared_balance = pg_atomic_add_fetch_u32(VacuumSharedCostBalance, VacuumCostBalance);
> 2073
> 2074 /* Compute the total local balance for the current worker */
> 2075 VacuumCostBalanceLocal += VacuumCostBalance;
> 2076
> 2077 if ((shared_balance >= VacuumCostLimit) &&
> >>> CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> >>> Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient to type "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?
Greetings,
Andres Freund
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-30 02:08 Amit Kapila <amit.kapila16@gmail.com>
parent: Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 10+ messages in thread
From: Amit Kapila @ 2020-03-30 02:08 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Mon, Mar 30, 2020 at 4:18 AM Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> On 2020-01-20 02:33:34 +0000, Amit Kapila wrote:
> > Allow vacuum command to process indexes in parallel.
> >
> > This feature allows the vacuum to leverage multiple CPUs in order to
> > process indexes. This enables us to perform index vacuuming and index
> > cleanup with background workers. This adds a PARALLEL option to VACUUM
> > command where the user can specify the number of workers that can be used
> > to perform the command which is limited by the number of indexes on a
> > table. Specifying zero as a number of workers will disable parallelism.
> > This option can't be used with the FULL option.
> >
> > Each index is processed by at most one vacuum process. Therefore parallel
> > vacuum can be used when the table has at least two indexes.
> >
> > The parallel degree is either specified by the user or determined based on
> > the number of indexes that the table has, and further limited by
> > max_parallel_maintenance_workers. The index can participate in parallel
> > vacuum iff it's size is greater than min_parallel_index_scan_size.
> >
> > Author: Masahiko Sawada and Amit Kapila
> > Reviewed-by: Dilip Kumar, Amit Kapila, Robert Haas, Tomas Vondra,
> > Mahendra Singh and Sergei Kornilov
> > Tested-by: Mahendra Singh and Prabhat Sahu
> > Discussion:
> > https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.com
> > https://postgr.es/m/CAA4eK1J-VoR9gzS5E75pcD-OH0mEyCdp8RihcwKrcuw7J-Q0+w@mail.gmail.com
>
> Coverity is complaining that:
> > ** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
> >
> >
> > ________________________________________________________________________________________________________
> > *** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
> > 2072 shared_balance = pg_atomic_add_fetch_u32(VacuumSharedCostBalance, VacuumCostBalance);
> > 2073
> > 2074 /* Compute the total local balance for the current worker */
> > 2075 VacuumCostBalanceLocal += VacuumCostBalance;
> > 2076
> > 2077 if ((shared_balance >= VacuumCostLimit) &&
> > >>> CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > >>> Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient to type "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.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-30 03:00 Mahendra Singh Thalor <mahi6run@gmail.com>
parent: Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Mahendra Singh Thalor @ 2020-03-30 03:00 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Mon, 30 Mar 2020 at 07:39, Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Mon, Mar 30, 2020 at 4:18 AM Andres Freund <andres@anarazel.de> wrote:
> >
> > Hi,
> >
> > On 2020-01-20 02:33:34 +0000, Amit Kapila wrote:
> > > Allow vacuum command to process indexes in parallel.
> > >
> > > This feature allows the vacuum to leverage multiple CPUs in order to
> > > process indexes. This enables us to perform index vacuuming and index
> > > cleanup with background workers. This adds a PARALLEL option to VACUUM
> > > command where the user can specify the number of workers that can be used
> > > to perform the command which is limited by the number of indexes on a
> > > table. Specifying zero as a number of workers will disable parallelism.
> > > This option can't be used with the FULL option.
> > >
> > > Each index is processed by at most one vacuum process. Therefore parallel
> > > vacuum can be used when the table has at least two indexes.
> > >
> > > The parallel degree is either specified by the user or determined based on
> > > the number of indexes that the table has, and further limited by
> > > max_parallel_maintenance_workers. The index can participate in parallel
> > > vacuum iff it's size is greater than min_parallel_index_scan_size.
> > >
> > > Author: Masahiko Sawada and Amit Kapila
> > > Reviewed-by: Dilip Kumar, Amit Kapila, Robert Haas, Tomas Vondra,
> > > Mahendra Singh and Sergei Kornilov
> > > Tested-by: Mahendra Singh and Prabhat Sahu
> > > Discussion:
> > > https://postgr.es/m/CAD21AoDTPMgzSkV4E3SFo1CH_x50bf5PqZFQf4jmqjk-C03BWg@mail.gmail.com
> > > https://postgr.es/m/CAA4eK1J-VoR9gzS5E75pcD-OH0mEyCdp8RihcwKrcuw7J-Q0+w@mail.gmail.com
> >
> > Coverity is complaining that:
> > > ** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > > /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
> > >
> > >
> > > ________________________________________________________________________________________________________
> > > *** CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > > /srv/coverity/git/pgsql-git/postgresql/src/backend/commands/vacuum.c: 2078 in compute_parallel_delay()
> > > 2072 shared_balance = pg_atomic_add_fetch_u32(VacuumSharedCostBalance, VacuumCostBalance);
> > > 2073
> > > 2074 /* Compute the total local balance for the current worker */
> > > 2075 VacuumCostBalanceLocal += VacuumCostBalance;
> > > 2076
> > > 2077 if ((shared_balance >= VacuumCostLimit) &&
> > > >>> CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > > >>> Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient to type "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.
--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com
Attachments:
v001-Fix-warning-in-compute_parallel_delay-for-Coverity.patch (application/octet-stream, 940B) download
From 8abb8b44f857bfe529a34ce0b57885dd062e2f62 Mon Sep 17 00:00:00 2001
From: Mahendra Singh Thalor <mahi6run@gmail.com>
Date: Sun, 29 Mar 2020 19:44:43 -0700
Subject: [PATCH] Fix warning in compute_parallel_delay for Coverity
---
src/backend/commands/vacuum.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 59731d687f..c5c7a452fc 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -2077,7 +2077,7 @@ compute_parallel_delay(void)
VacuumCostBalanceLocal += VacuumCostBalance;
if ((shared_balance >= VacuumCostLimit) &&
- (VacuumCostBalanceLocal > 0.5 * (VacuumCostLimit / nworkers)))
+ (VacuumCostBalanceLocal > (int) (0.5 * ((double) VacuumCostLimit / nworkers))))
{
/* Compute sleep time based on the local cost balance */
msec = VacuumCostDelay * VacuumCostBalanceLocal / VacuumCostLimit;
--
2.17.1
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-30 04:14 Amit Kapila <amit.kapila16@gmail.com>
parent: Andres Freund <andres@anarazel.de>
1 sibling, 1 reply; 10+ messages in thread
From: Amit Kapila @ 2020-03-30 04:14 UTC (permalink / raw)
To: Andres Freund <andres@anarazel.de>; +Cc: Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Mon, Mar 30, 2020 at 4:18 AM Andres Freund <andres@anarazel.de> wrote:
>
> > 2076
> > 2077 if ((shared_balance >= VacuumCostLimit) &&
> > >>> CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > >>> Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient to type "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?
>
Yeah, how can we set up and test a fix for this? Where can I see these results?
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-31 07:43 Mahendra Singh Thalor <mahi6run@gmail.com>
parent: Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Mahendra Singh Thalor @ 2020-03-31 07:43 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Mon, 30 Mar 2020 at 09:44, Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Mon, Mar 30, 2020 at 4:18 AM Andres Freund <andres@anarazel.de> wrote:
> >
> > > 2076
> > > 2077 if ((shared_balance >= VacuumCostLimit) &&
> > > >>> CID ...: Incorrect expression (UNINTENDED_INTEGER_DIVISION)
> > > >>> Dividing integer expressions "VacuumCostLimit" and "nworkers", and then converting the integer quotient to type "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?
> >
>
> Yeah, how can we set up and test a fix for this? Where can I see these results?
I am able to make coverity setup. I am verifying fix and will post my
results in coming days.
--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-31 07:45 Andres Freund <andres@anarazel.de>
parent: Mahendra Singh Thalor <mahi6run@gmail.com>
0 siblings, 0 replies; 10+ messages in thread
From: Andres Freund @ 2020-03-31 07:45 UTC (permalink / raw)
To: Mahendra Singh Thalor <mahi6run@gmail.com>; Amit Kapila <amit.kapila16@gmail.com>; +Cc: Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
Hi,
On March 31, 2020 12:43:47 AM PDT, Mahendra Singh Thalor <mahi6run@gmail.com> wrote:
>On Mon, 30 Mar 2020 at 09:44, Amit Kapila <amit.kapila16@gmail.com>
>wrote:
>>
>> On Mon, Mar 30, 2020 at 4:18 AM Andres Freund <andres@anarazel.de>
>wrote:
>> >
>> > > 2076
>> > > 2077 if ((shared_balance >= VacuumCostLimit) &&
>> > > >>> CID ...: Incorrect expression
>(UNINTENDED_INTEGER_DIVISION)
>> > > >>> Dividing integer expressions "VacuumCostLimit" and
>"nworkers", and then converting the integer quotient to type "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?
>> >
>>
>> Yeah, how can we set up and test a fix for this? Where can I see
>these results?
>
>I am able to make coverity setup. I am verifying fix and will post my
>results in coming days.
That doesn't seem necessary - we should commit a fix. We'll know in a few days for sure. But it's not hard to just theoretically look at the issue in this case?
Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-03-31 11:58 Amit Kapila <amit.kapila16@gmail.com>
parent: Mahendra Singh Thalor <mahi6run@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Amit Kapila @ 2020-03-31 11:58 UTC (permalink / raw)
To: Mahendra Singh Thalor <mahi6run@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
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 to type "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
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-04-01 03:09 Mahendra Singh Thalor <mahi6run@gmail.com>
parent: Amit Kapila <amit.kapila16@gmail.com>
0 siblings, 1 reply; 10+ messages in thread
From: Mahendra Singh Thalor @ 2020-04-01 03:09 UTC (permalink / raw)
To: Amit Kapila <amit.kapila16@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Tue, 31 Mar 2020 at 17:28, Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> 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 to type "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.
I also think same so attaching updated patch.
--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com
Attachments:
v002-Fix-warning-in-compute_parallel_delay-for-Coverity.patch (application/octet-stream, 932B) download
From 9f0fedf6fa75ef4fffde2272a587d4b0bf799344 Mon Sep 17 00:00:00 2001
From: Mahendra Singh Thalor <mahi6run@gmail.com>
Date: Tue, 31 Mar 2020 20:04:16 -0700
Subject: [PATCH] Fix warning in compute_parallel_delay for Coverity
---
src/backend/commands/vacuum.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 59731d687f..3a89f8fe1e 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -2077,7 +2077,7 @@ compute_parallel_delay(void)
VacuumCostBalanceLocal += VacuumCostBalance;
if ((shared_balance >= VacuumCostLimit) &&
- (VacuumCostBalanceLocal > 0.5 * (VacuumCostLimit / nworkers)))
+ (VacuumCostBalanceLocal > 0.5 * ((double) VacuumCostLimit / nworkers)))
{
/* Compute sleep time based on the local cost balance */
msec = VacuumCostDelay * VacuumCostBalanceLocal / VacuumCostLimit;
--
2.17.1
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: pgsql: Allow vacuum command to process indexes in parallel.
@ 2020-04-02 02:14 Amit Kapila <amit.kapila16@gmail.com>
parent: Mahendra Singh Thalor <mahi6run@gmail.com>
0 siblings, 0 replies; 10+ messages in thread
From: Amit Kapila @ 2020-04-02 02:14 UTC (permalink / raw)
To: Mahendra Singh Thalor <mahi6run@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Amit Kapila <akapila@postgresql.org>; pgsql-committers@lists.postgresql.org
On Wed, Apr 1, 2020 at 8:39 AM Mahendra Singh Thalor <mahi6run@gmail.com> wrote:
>
> On Tue, 31 Mar 2020 at 17:28, Amit Kapila <amit.kapila16@gmail.com> wrote:
> >
> > 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 to type "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.
>
> I also think same so attaching updated patch.
>
Thanks, I have pushed this patch yesterday.
--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2020-04-02 02:14 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 02:33 pgsql: Allow vacuum command to process indexes in parallel. Amit Kapila <akapila@postgresql.org>
2020-03-29 22:48 ` Andres Freund <andres@anarazel.de>
2020-03-30 02:08 ` Amit Kapila <amit.kapila16@gmail.com>
2020-03-30 03:00 ` Mahendra Singh Thalor <mahi6run@gmail.com>
2020-03-31 11:58 ` Amit Kapila <amit.kapila16@gmail.com>
2020-04-01 03:09 ` Mahendra Singh Thalor <mahi6run@gmail.com>
2020-04-02 02:14 ` Amit Kapila <amit.kapila16@gmail.com>
2020-03-30 04:14 ` Amit Kapila <amit.kapila16@gmail.com>
2020-03-31 07:43 ` Mahendra Singh Thalor <mahi6run@gmail.com>
2020-03-31 07:45 ` Andres Freund <andres@anarazel.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox