Re: tablecmds: fix bug where index rebuild loses replica identity on partitions

From: "Alberto Piai" <alberto(dot)piai(at)gmail(dot)com>
To: "Sami Imseih" <samimseih(at)gmail(dot)com>, "Alberto Piai" <alberto(dot)piai(at)gmail(dot)com>
Cc: "Chao Li" <li(dot)evan(dot)chao(at)gmail(dot)com>, "Postgres hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Xuneng Zhou" <xunengzhou(at)gmail(dot)com>, "Michael Paquier" <michael(at)paquier(dot)xyz>, "Robert Treat" <rob(at)xzilla(dot)net>
Subject: Re: tablecmds: fix bug where index rebuild loses replica identity on partitions
Date: 2026-07-28 06:50:55
Message-ID: DKA06URPT1BS.VMPKMBIU9JQQ@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue Jul 28, 2026 at 1:11 AM CEST, Sami Imseih wrote:
>> Also, this issue is not limited to replica identity. CLUSTER ON does
>> not copy/restore indisclustered on partition indexes at all, and this
>> should be addressed as well, right?
>
> Robert (cc'd) reminded me offline that REPACK ... USING INDEX ==
> CLUSTER ON.

Hi Sami,

have you seen my email from a few days ago?

https://www.postgresql.org/message-id/DK5H6VM4U4J4.C8APP2ZH2CAT%40gmail.com

I'm pretty sure the root cause is not addressed by patch v9.

If my analysis is correct (RememberIndexForRebuilding not being called
on the child index because of an earlier drop), that would also explain
the issues with CLUSTER (As RememberIndexForRebuilding calls both
RememberReplicaIdentityForRebuilding and
RememberClusterOnForRebuilding).

In that case, rather than tracking and restoring more state, I think a
better fix would be to make sure that ATPostAlterTypeCleanup doesn't
find the child table in a half-cleaned-up state. Then
RememberIndexForRebuilding would be called and the replica identity and
cluster state would be restored correctly.

Regards,

Alberto

--
Alberto Piai
Sensational AG
Zürich, Switzerland

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-07-28 07:02:48 Re: sequencesync worker race with REFRESH SEQUENCES
Previous Message Michael Paquier 2026-07-28 06:47:18 Re: [PATCH] Harden two-phase GID handling and fork-number validation in WAL replay/decode paths