Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table
Date
Msg-id ZeAaH7GQobcZync0@paquier.xyz
Whole thread Raw
In response to Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table  (Alexander Lakhin <exclusion@gmail.com>)
List pgsql-bugs
On Mon, Feb 26, 2024 at 09:00:01AM +0300, Alexander Lakhin wrote:
> It looks like currentlyReindexedIndex == 0 in this case, so
> ReindexIsProcessingIndex() doesn't guard against get_relation_info() ->
> _bt_getrootheight() -> _bt_getbuf() -> ReadBuffer() -> ... -> mdread().

Fun.  The concurrent case is actually able to work because it looks
like the basic definition of the relation exists with its relfilenode.

I was looking at that, and it seems to me that the point is not that
the index is being reindexed; the point is that we want to prevent
access to the index itself while it being built.  And that's something
that can happen for a reindex as much as a new index.  It would be
possible to paint an equivalent of SetReindexProcessing() in
index_create() for index_build() where a trace of the index OID
getting built is kept around, and it would be possible to trigger the
same  error as when doing a reindex.  Hence, if we were to do that,
the current ReindexIs*() routines maintaining the list of the indexes
being built across transaction states are a bit misnamed, and the
error messages would be partially incorrect.

I am not sure if this is worth bothering beyond HEAD, or worth
bothering at all, but seeing 940489b467 it looks like we do bother
even for stable branches.
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Feature bug dumpall CREATE ROLE postgres
Next
From: "David G. Johnston"
Date:
Subject: Re: `order by random()` makes select-list `random()` invocations deterministic