public inbox for [email protected]
help / color / mirror / Atom feedFrom: Mohamed ALi <[email protected]>
To: Sami Imseih <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Haibo Yan <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Fix: Partitioned parent index remains invalid after child indexes are repaired
Date: Wed, 29 Apr 2026 14:36:09 -0700
Message-ID: <CAGnOmWpHu25_LpT=zv7KtetQhqV1QEZzFYLd_TDyOLu1Od9fpw@mail.gmail.com> (raw)
In-Reply-To: <CAA5RZ0sQfnLyv2Ta-r6y==QwwUr+M0BxVbK0=0_HZZA1ywc3Bw@mail.gmail.com>
References: <CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf=6sKhbf4sHLs5xAcKVCMQ@mail.gmail.com>
<CABXr29GbJe7-vbm0Fn=HWx3vQonwFtv_zO1pSc5FZAvjLuUDVA@mail.gmail.com>
<CABXr29Epj=23eYAWg_mTdiXYQQzJSVN22uk6tK8ei0ts5wXvSQ@mail.gmail.com>
<CAA5RZ0s16eHrzcDupipAxC++e-p_n_M7Fpg-MG-V59fB=wykLw@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAA5RZ0uM7_YPdSahGh1sGeewMb9SzKswyLaZty8aR+a7XpQydQ@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAA5RZ0sQfnLyv2Ta-r6y==QwwUr+M0BxVbK0=0_HZZA1ywc3Bw@mail.gmail.com>
Hi Michael, Sami, Haibo,
Thank you all for the reviews and for committing the fix (9d3e094f12).
I'm glad to see this backpatched through PostgreSQL 14.
Sami's targeted approach — only calling validatePartitionedIndex()
when the index is already attached AND the parent is currently
invalid — is clean and avoids the concerns Haibo raised about
turning the no-op path into a generic validation hook. Good call.
I noticed that the commit did not include a documentation update
for ALTER INDEX ATTACH PARTITION.
There is no mention that re-running the command on an already-attached
index will attempt to validate the parent. Users who hit this bug
would have no way to discover the recovery path from the docs alone —
they would need to find the mailing list thread or read the commit
message.
I have attached a small doc-only patch that adds a paragraph to the
ALTER INDEX documentation:
"If the named index is already attached to the altered index, the
command will attempt to validate the parent index if the parent
is currently invalid."
This applies on top of current HEAD (which includes 9d3e094f12).
Since the code change was backpatched to 14, the doc update should
probably be backpatched to the same branches.
Thanks,
Mohamed Ali
AWS RDS
On Wed, Apr 22, 2026 at 3:33 AM Sami Imseih <[email protected]> wrote:
>
> > > One thing that I'm tempted to add is more scans to check indisvalid
> > > across these commands, particularly after the individual ATTACH
> > > PARTITION bits on each individual index.
>
> That works.
>
> > > A second thing. Do you think that it would be worth adding a
> > > partitioned table that has no leaves in some portion of the test? I
> > > was thinking about a partitioned table called idxpart2 attached to
> > > idxpart in the first part of the test. I've found this pattern
> > > usually useful for this area of the code when recursing with
> > > validatePartitionedIndex() from a parent.
>
> Good idea.
>
> > Both things have been added to the tests, and applied the result down
> > to v14. The patch was able to apply cleanly across the board, without
> > conflicts. That's rare, these days..
>
> Sorry for the late reply, and thanks for getting this committed!
>
> --
> Sami Imseih
> Amazon Web Services (AWS)
Attachments:
[application/octet-stream] v1-0001-doc-ALTER-INDEX-ATTACH-PARTITION-validation.patch (1.7K, 2-v1-0001-doc-ALTER-INDEX-ATTACH-PARTITION-validation.patch)
download | inline diff:
From 164f25122bc2170218828606b9466b873b1ce67b Mon Sep 17 00:00:00 2001
From: Mohamed ALi <[email protected]>
Date: Wed, 29 Apr 2026 13:54:40 -0700
Subject: [PATCH] doc: Document parent index validation in ALTER INDEX ATTACH
PARTITION
Commit 9d3e094f12 added the ability for ALTER INDEX ... ATTACH
PARTITION to validate a parent partitioned index when the partition
index is already attached but the parent is still invalid. This
provides a recovery path when a previously invalid partition index
has been repaired via REINDEX.
However, the documentation for ALTER INDEX ATTACH PARTITION was not
updated to describe this behavior. Users have no way to discover
this recovery path from the docs alone.
Add a paragraph to the ALTER INDEX documentation explaining that
re-running ATTACH PARTITION on an already-attached index will
attempt to validate the parent if it is currently invalid.
Discussion: https://www.postgresql.org/message-id/CAGnOmWqi1D9ycBgUeOGf6mOCd2Dcf%3D6sKhbf4sHLs5xAcKVCMQ%40mail.gmail.com
---
doc/src/sgml/ref/alter_index.sgml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/doc/src/sgml/ref/alter_index.sgml b/doc/src/sgml/ref/alter_index.sgml
index 1d42d05..2a119f5 100644
--- a/doc/src/sgml/ref/alter_index.sgml
+++ b/doc/src/sgml/ref/alter_index.sgml
@@ -97,6 +97,14 @@ ALTER INDEX ALL IN TABLESPACE <replaceable class="parameter">name</replaceable>
index cannot be dropped by itself, and will automatically be dropped
if its parent index is dropped.
</para>
+ <para>
+ If the named index is already attached to the altered index, the
+ command will attempt to validate the parent index if the parent is
+ currently invalid.
+ </para>
</listitem>
</varlistentry>
--
2.50.1 (Apple Git-155)
view thread (12+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PATCH] Fix: Partitioned parent index remains invalid after child indexes are repaired
In-Reply-To: <CAGnOmWpHu25_LpT=zv7KtetQhqV1QEZzFYLd_TDyOLu1Od9fpw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox