Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18363: Assert !ReindexIsProcessingIndex falsified with expression index over select from table
Date: 2024-02-29 05:46:07
Message-ID: ZeAaH7GQobcZync0@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2024-02-29 05:53:09 Re: `order by random()` makes select-list `random()` invocations deterministic
Previous Message Tender Wang 2024-02-29 05:25:20 Re: "type with xxxx does not exist" when doing ExecMemoize()