Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data

From: Noah Misch <noah(at)leadboat(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Date: 2021-09-08 06:45:15
Message-ID: 20210908064515.GA2496820@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, Aug 29, 2021 at 11:38:03PM +0500, Andrey Borodin wrote:
> > 29 авг. 2021 г., в 23:09, Andres Freund <andres(at)anarazel(dot)de> написал(а):
> >>> It seems like it's going to add a substantial amount of work even when
> >>> no 2PC xacts are involved?
> >> Only if 2PCs are enabled.
> >
> > I don't think that's good enough. Plenty of systems have 2PC enabled but very
> > few if any transactions end up as 2PC ones.

> Best optimisation I can imagine here is to gather all vxids with unknown xids and search for them in one call to TwoPhaseGetXidByVXid() with one LWLockAcquire(TwoPhaseStateLock, LW_SHARED).
>
> Does it worth the complexity?

https://www.postgresql.org/search/?m=1&q=TwoPhaseStateLock&l=&d=-1&s=r
suggests this is the first postgresql.org discussion of TwoPhaseStateLock as a
bottleneck. Nonetheless, if Andres Freund finds it's worth the complexity,
then I'm content with it. I'd certainly expect some performance benefit.
Andres, what do you think?

We could start with an unlocked scan of the twophase shared memory. If the
unlocked scan finds a potential match, acquire TwoPhaseStateLock and repeat
the scan. Otherwise, we don't need the locked scan, because we can deduce
that the locked scan would find nothing. I'm not fond of relying on such
reasoning without a known-strong performance need, but it's an alternative.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-09-08 07:21:18 BUG #17184: When using openssl, the memory of a static variable is not freed in libpq
Previous Message PG Bug reporting form 2021-09-08 02:08:26 BUG #17183: missing websearch_to_tsquery