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

From: Noah Misch <noah(at)leadboat(dot)com>
To: 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>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: CREATE INDEX CONCURRENTLY does not index prepared xact's data
Date: 2021-10-19 03:02:12
Message-ID: 20211019030212.GB3403374@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Oct 18, 2021 at 06:23:05PM +0500, Andrey Borodin wrote:
> > 17 окт. 2021 г., в 20:12, Noah Misch <noah(at)leadboat(dot)com> написал(а):
> > I think the attached version is ready for commit. Notable differences
> > vs. v14:
> Few notes:
>
> 1. Maybe an Assert(in_progress_list_maxlen) when in_progress_list_maxlen is used?

RelationCacheInitialize() initializes both in_progress_list_maxlen and the
RelationIdCache hash table, and any ERROR there is promoted to FATAL. Without
the hash table, nothing good can happen in relcache. Hence, I think such an
assert is excessive.

> 2.
> -#define VirtualTransactionIdIsPreparedXact(vxid) \
> +#define VirtualTransactionIdIsRecoveredPreparedXact(vxid) \
>
> This is a very neat transition. Yes, the function argument will always be a xid only for recovered transactions. Maybe add a comment here that this function is expected to be used only for results of GetLockConflicts()?

One can use it on any VirtualTransactionId, though some sources only return
values for which this returns false. It can return true for the result of
GET_VXID_FROM_PGPROC(). I think it can return true for the result of
GetCurrentVirtualXIDs(limitXmin = InvalidTransactionId), but core code doesn't
make such a call.

> > One thing not done here is to change the tests to use CREATE INDEX
> > CONCURRENTLY instead of REINDEX CONCURRENTLY, so they're back-patchable to v11
> > and earlier. I may do that before pushing, or I may just omit the tests from
> > older branches.
>
> The tests refactors PostgresNode.pm and some tests. Back-patching this would be quite invasive.

That's fine with me. Back-patching a fix without its tests is riskier than
back-patching test infrastructure changes.

> But swapping every "REINDEX INDEX CONCURRENTLY idx;" with
> DROP INDEX CONCURRENTLY idx;
> CREATE INDEX CONCURRENTLY idx on tbl(i);
> works.
>
> > <inval-build-race-v1.patch><prepared-transactions-cic-series202107-v15nm.patch>
> I've checked that this patches work for some time on my machines. I do not observe failures.

Good. Thanks for checking.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bossart, Nathan 2021-10-19 03:07:51 Re: BUG #17220: ALTER INDEX ALTER COLUMN SET (..) with an optionless opclass makes index and table unusable
Previous Message Tom Lane 2021-10-19 02:10:46 Re: BUG #17236: Postgres core on pstate->p_multiassign_exprs