From: David Gould <daveg@sonic.net>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Cc: Josh Berkus <josh@agliodbs.com>
Subject: Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower.
Date: Wed, 16 Mar 2016 14:00:38 -0700
Message-ID: <20160316140038.06a1934d@engels> (raw)
In-Reply-To: <20160315142816.5dca09dd@engels>
References: <20160302034537.0b1c2da7@engels>
<20160315204026.GA29216@alvherre.pgsql>
<20160315142816.5dca09dd@engels>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Tue, 15 Mar 2016 14:28:16 -0700
David Gould <daveg@sonic.net> wrote:
> On Tue, 15 Mar 2016 17:40:26 -0300
> Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>
> > David Gould wrote:
> > > On Mon, 29 Feb 2016 18:33:50 -0300
> > > Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> > >
> > > > Hi David, did you ever post an updated version of this patch?
> > >
> > > No. Let me fix that now. I've attached my current revision of the patch
> > > based on master. This version is significantly better than the original
> > > version and resolves multiple issues:
> >
> > Thanks for the patch. I spent some time studying it and testing it. I
> > think there's a minor bug in this latest version: the "continue" when
> > the "for" loop exits because of all relids being less than
> > highest_oid_claimed should be a "break" instead. Otherwise the worker
> > will uselessly loop over the whole list of OIDs only to find each time
> > that it has nothing to do.
>
> Good catch. Thanks!
Actually, looking at this more closely, I don't see the problem.
I'm assuming you meant the continue after "if (relid ==InvalidOid)":
/*
* 2. While there are items that have not been visited...
*/
for(oid_idx = 0; oid_idx < numoids; )
{
...
/*
* 4a. Skip past the highest_oid_claimed to find the next oid to work on.
*/
relid = InvalidOid;
while (relid <= highest_oid_claimed && oid_idx < numoids)
relid = table_oids[oid_idx++];
if (relid <= highest_oid_claimed)
relid = InvalidOid;
/* 4b. Claim the chosen table by storing its oid in shared memory. */
MyWorkerInfo->wi_tableoid = relid;
LWLockRelease(AutovacuumLock);
/* If we reached the end of the list there is nothing to do. */
if (relid == InvalidOid)
continue;
...
}
At the continue oid_idx will have been incremented by:
while (relid <= highest_oid_claimed && oid_idx < numoids)
relid = table_oids[oid_idx++];
to be equal to numoids so the for loop will exit immediately as the loop
condition is "oid_idx < numoids".
"break" would work as well, but basically there is only one reason to exit
the for loop, exhausting the list of oids, so continue seemed preferable.
Or am I missing something?
-dg
--
David Gould 510 282 0869 daveg@sonic.net
If simplicity worked, the world would be overrun with insects.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: daveg@sonic.net, alvherre@2ndquadrant.com, jeff.janes@gmail.com, tgl@sss.pgh.pa.us, josh@agliodbs.com
Subject: Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower.
In-Reply-To: <20160316140038.06a1934d@engels>
References: <20160302034537.0b1c2da7@engels> <20160315204026.GA29216@alvherre.pgsql> <20160315142816.5dca09dd@engels> <20160316140038.06a1934d@engels>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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