Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail
Date: 2019-07-18 04:25:43
Message-ID: 20190718042543.GE1416@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jul 18, 2019 at 12:02:32PM +0900, Michael Paquier wrote:
> There are a couple of approaches that we could do to fix that. The
> first one I could think about is to change the relcache level so as we
> don't apply planner-level optimizations when creating a concurrent
> index entry. Another one, which is less invasive, is to just update
> the list of expressions and predicates after calling
> BuildIndexInfo(). Still that means overriding the contents of the
> relcache with what has been optimized for the planner to what we want
> to use for the reindex build and I think that this weakens the logic
> of index_build.

I have done some work on that, and for now I am finishing with the
attached. This takes the approach of updating BuildIndexInfo() so as
the optimizations for the planner are not done.

That's not completely right yet though as even if it passes your
initial test case, this does not allow the index expressions and
predicates to have an exact match. I have designed a test case for
this purpose which stores the contents of pg_node_tree before and
after the REINDEX and even if the collation gets right, all the
location fields from pg_node_tree get reset. The solution is not
complete, still the test case is quite useful. So even if the
solution happens to not be like the attached, I'd rather keep the
test case and perhaps extend it.
--
Michael

Attachment Content-Type Size
reindex-conc-predicates-v1.patch text/x-diff 23.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-07-18 08:32:04 BUG #15916: Confusing upgrade message
Previous Message Tom Lane 2019-07-18 03:57:03 Re: BUG #15915: ALTER COLUMN SET DATA TYPE fails with index already exists