From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: James Coleman <jtc331@gmail.com>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: remove spurious CREATE INDEX CONCURRENTLY wait
Date: Tue, 17 Nov 2020 12:55:01 -0300
Message-ID: <20201117155501.GA13805@alvherre.pgsql> (raw)
In-Reply-To: <20201117000832.GA19824@alvherre.pgsql>
On 2020-Nov-16, Alvaro Herrera wrote:
> On 2020-Nov-09, Tom Lane wrote:
>
> > Michael Paquier <michael@paquier.xyz> writes:
> > >> + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
> > >> + MyProc->vacuumFlags |= PROC_IN_SAFE_IC;
> > >> + ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags;
> > >> + LWLockRelease(ProcArrayLock);
> >
> > > I can't help noticing that you are repeating the same code pattern
> > > eight times. I think that this should be in its own routine, and that
> > > we had better document that this should be called just after starting
> > > a transaction, with an assertion enforcing that.
> >
> > Do we really need exclusive lock on the ProcArray to make this flag
> > change? That seems pretty bad from a concurrency standpoint.
>
> BTW I now know that the reason for taking ProcArrayLock is not the
> vacuumFlags itself, but rather MyProc->pgxactoff, which can move.
... ah, but I realize now that this means that we can use shared lock
here, not exclusive, which is already an enormous improvement. That's
because ->pgxactoff can only be changed with exclusive lock held; so as
long as we hold shared, the array item cannot move.
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@alvh.no-ip.org, tgl@sss.pgh.pa.us, michael@paquier.xyz, 9erthalion6@gmail.com, jtc331@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: remove spurious CREATE INDEX CONCURRENTLY wait
In-Reply-To: <20201117155501.GA13805@alvherre.pgsql>
* 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