Crashes on a partition whose concurrent detach never finished

Поиск
Список
Период
Сортировка
Искать

Crashes on a partition whose concurrent detach never finished

От:
Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Дата:
Вложения:
Hello, everyone! (Added CC to authors of patches that introduced the
issues described below, sorry if it is duplicate for you).

I was working on stress-suite and discovered a few crashes caused
mainly by the same issue.

DETACH PARTITION ... CONCURRENTLY marks the partition and commits, and
only then waits. If that wait is interrupted the mark remains.
Only PARTITION ... FINALIZE clears it. Reaching this needs no race,
and the state outlives the command that made it.

In that state pg_class still says relispartition, while
get_partition_ancestors() already reports nothing.

Three places read the former as meaning the latter is not empty and
ask for its last element, which causes an assert() or NPE:

- get_rel_sync_entry()
- getIdentitySequence()
- RelationBuildPublicationDesc()

The last one is a v19 regression, so I think it may be added to the
open items list.

Patches are attached, one for each place; each includes a test that
reproduces the crash.

Best regards,
Mikhail.

Re: Crashes on a partition whose concurrent detach never finished

От:
Nathan Bossart <nathandbossart@gmail.com>
Дата:
Does this one deserve a mention on the open items wiki [0]?

[0] https://wiki.postgresql.org/wiki/PostgreSQL_19_Open_Items

-- 
nathan


Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
Вложения:
On Thu, Sep 10, 2026 at 7:40 PM Nisha Moond  wrote:
>
> On Thu, Sep 10, 2026 at 5:37 PM shveta malik  wrote:
> > > ~~~
> > >
> > > Given that we are treating a detach-pending partition as an individual
> > > table for publication decisions, the changes in patch-003 (pg19
> > > regression) look correct to me. The changes in relcache.c correctly
> > > treat the detach-pending partition as an individual table.
> > >
> >
> > I haven't had a chance to reveiw 003 yet as 001 itself was
> > problematic. Will review it tomorrow.
> >
>
> Here is a rebased version of 003 that applies independently on both
> HEAD and pg19. This should make reviewing patch-003 separately easier.
>

Okay, the fix looks good. I verified that it fixes the crash on HEAD.
But it would be good to change the fix slightly to be consistent with
001. See the attached changes for reference.

thanks
Shveta

Re: Crashes on a partition whose concurrent detach never finished

От:
Zsolt Parragi <zsolt.parragi@percona.com>
Дата:
Вложения:
Hello!

An automated claude review found a residual crash in pgoutput after
the committed fix, which repeatedly crashes the walsender following an
interrupted ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY.

0001 contains a test case and a simple fix.

And after further looking, I realized that there's one more leftover
issue, which doesn't cause a crash but failures in subscribers:
pg_get_publication_tables only relied on relispartition instead of
following the same approach as the previous fix commit and 0001. 0002
modifies it to match the other locations.

Re: Crashes on a partition whose concurrent detach never finished

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Tue, Sep 22, 2026 at 2:31 AM Zsolt Parragi  wrote:
>
> Hello!
>
> An automated claude review found a residual crash in pgoutput after
> the committed fix, which repeatedly crashes the walsender following an
> interrupted ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY.
>
> 0001 contains a test case and a simple fix.
>

Thanks for looking into this.
The issue that the 0001 patch you shared is trying to fix is the same
one reported upthread [1] in the v1-0001 patch.
The fix is still under discussion and is not a PG19 regression. We
need a detailed analysis of the expected behavior for detached-pending
partitions requiring relcache invalidation and its side-effects,
please see discussions [2],[3].

> And after further looking, I realized that there's one more leftover
> issue, which doesn't cause a crash but failures in subscribers:
> pg_get_publication_tables only relied on relispartition instead of
> following the same approach as the previous fix commit and 0001. 0002
> modifies it to match the other locations.

Good catch!
Here is my analysis of the 0002 fix:
It is a pre-existing bug, not an EXCEPT TABLE feature regression.
0002 fixes one thing: a detach-pending partition is skipped under
publish_via_partition_root = true, with or without an EXCEPT clause.
EXCEPT just makes it easy to reproduce; I think the core problem is
how the publishable decision is taken when pubviaroot = true.

Two parts:
1) GetAllPublicationRelations(): pre-existing, reachable since v14
Example: table t_part has t_part_p1, t_part_p2; t_part_p2 is detach-pending:

CREATE PUBLICATION pub_root FOR ALL TABLES WITH
(publish_via_partition_root = true);
CREATE PUBLICATION pub_leaf FOR ALL TABLES;

-- before (head):
  postgres=# SELECT pubname, tablename FROM pg_publication_tables
WHERE tablename LIKE 't_part%';
   pubname  | tablename
  ----------+-----------
   pub_root | t_part
   pub_leaf | t_part_p1
   pub_leaf | t_part_p2

-- after (0002 fix):
  postgres=# SELECT pubname, tablename FROM pg_publication_tables
WHERE tablename LIKE 't_part%';
   pubname  | tablename
  ----------+-----------
   pub_root | t_part_p2
   pub_root | t_part
   pub_leaf | t_part_p2
   pub_leaf | t_part_p1

-- pub_root does not list t_part_p2, although the decoding side
publishes it under its own name as we treat a detach-pending partition
as a standalone table everywhere else.

2) is_table_publishable_in_publication(): new function in v19, added by -

```
commit fd7a25af11e2cad4f48ffc4e50f18644e657ed53
Author: Masahiko Sawada 
Date:   Thu Apr 2 11:34:50 2026 -0700

    Add target_relid parameter to pg_get_publication_tables().
```

2a) for ALL TABLES, is the detach-pending partition publishable?

-- before (head)
postgres=# SELECT * FROM pg_get_publication_tables(ARRAY['pub_root'],
't_part_p2'::regclass::oid);
 pubid | relid | attrs | qual
-------+-------+-------+------
(0 rows)

postgres=# SELECT * FROM pg_get_publication_tables(ARRAY['pub_leaf'],
't_part_p2'::regclass::oid);
 pubid | relid | attrs | qual
-------+-------+-------+------
 16479 | 16475 | 1     |

-- after (0002 fix)
postgres=# SELECT * FROM pg_get_publication_tables(ARRAY['pub_root'],
't_part_p2'::regclass::oid);
 pubid | relid | attrs | qual
-------+-------+-------+------
 24581 | 16392 | 1     |

postgres=# SELECT * FROM pg_get_publication_tables(ARRAY['pub_leaf'],
't_part_p2'::regclass::oid);
 pubid | relid | attrs | qual
-------+-------+-------+------
 24582 | 16392 | 1     |

--  pub_root reports the detach-pending partition as not publishable
(0 rows), while pub_leaf reports it.

2b) For Non-ALL-TABLES publications, the behavior was already correct;
the change below is a no-op:

-    if (relispartition &&
+    if (ancestors &&
          OidIsValid(GetTopMostAncestorInPublication(pub->oid,
ancestors, NULL)))
         return !pub->pubviaroot;

For a detach-pending partition ancestors is empty, so
GetTopMostAncestorInPublication() already returned InvalidOid and the
branch was already not taken. But we can consider the change for
clarity/cost improvement.
~~~

[1] https://www.postgresql.org/message-id/CADzfLwWoFPT%2Ba73%3DA%3DbsNWRMZQ98NpBEMgE%3Dt1FS4O4_%3DQVLfA%40mail.gmail.com
[2] https://www.postgresql.org/message-id/CAJpy0uA6womAP7fkmT%3DsSfKG_0CfKUSb7HhP_J9mw071MXc39w%40mail.gmail.com
[3] https://www.postgresql.org/message-id/CABdArM4fJ8JAWyP0MAF%3D8n66M6%3DCouUmtSGwqizn2pD%3DgfPEZw%40mail.gmail.com

Thanks,
Nisha


Re: Crashes on a partition whose concurrent detach never finished

От:
Zsolt Parragi <zsolt.parragi@percona.com>
Дата:
> The issue that the 0001 patch you shared is trying to fix is the same
> one reported upthread

Ops, sorry for missing that, I only read the last few messages in the
thread properly and I didn't realize that it was a known issue. I'll
look into that discussion more.

> 2b) For Non-ALL-TABLES publications, the behavior was already correct;
> the change below is a no-op:

Yes, that part was a cosmetic change to make everything follow the
same approach, I don't think it causes any actual issues.


Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Tue, Sep 22, 2026 at 2:31 AM Zsolt Parragi  wrote:
>
> Hello!
>
> An automated claude review found a residual crash in pgoutput after
> the committed fix, which repeatedly crashes the walsender following an
> interrupted ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY.
>
> 0001 contains a test case and a simple fix.

Thanks for the patches. 001 is a known issue as Nisha pointed out.

> And after further looking, I realized that there's one more leftover
> issue, which doesn't cause a crash but failures in subscribers:
> pg_get_publication_tables only relied on relispartition instead of
> following the same approach as the previous fix commit and 0001. 0002
> modifies it to match the other locations.

I earlier pointed the issue in pg_get_publication_tables's
is_table_publishable_in_publication() in [1] (see pt b), which your
002 has addressed.  I agree with the problem and the fix for the HEAD.
I can reveiw in detail once we plan to address all such issues on
HEAD.

[1]:https://www.postgresql.org/message-id/CAJpy0uB-EpnNPUEFzLT38JX84swWFnsRbhPKCpnzSbnb1UNSmQ%40mail.gmail.com

thanks
Shveta


Re: Crashes on a partition whose concurrent detach never finished

От:
Mihail Nikalayeu <mihailnikalayeu@gmail.com>
Дата:
Вложения:
Hello, everyone!

Thanks to Amit for pushing, and to others for new findings and reviews.

Attached is v2 of the remaining fixes, rebased on master and
registered in the commitfest as [3] for tracking purposes.

I tried to combine everything into the series. It is mostly
AI-generated, but I still think structuring everything is helpful
anyway.

The rule throughout is that a partition pending detach is published as
a standalone table, as it will be after FINALIZE; publishing it via
the former root would cause the divergence Nisha described in [1].

0001 (pgoutput crash): The test comment Shveta asked about was
misleading; it's fixed. pgindent-clean applied.

0002 (identity sequence) gains a new test: an insert into a leaf under
a partition pending detach still finds the root's sequence.

0003 is Zsolt's fix for the inconsistency Shveta pointed out:
pg_get_publication_tables() now lists a partition with no active
ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.

Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).

The commit message now also says, as Nisha found in [2], that the full
list has been affected since 14, while the targeted lookup only exists
in 19.

0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
It also invalidates the descendants of a partitioned partition, as
Nisha suggested in [1], and locks them with AccessShareLock.

[1] https://www.postgresql.org/message-id/CABdArM4fJ8JAWyP0MAF%3D8n66M6%3DCouUmtSGwqizn2pD%3DgfPEZw%40mail.gmail.com
[2] https://www.postgresql.org/message-id/CABdArM7Bc7SZPSHk5uT-yA6%3DDYVFW-Os4noB6CANH6GQw9rvew%40mail.gmail.com
[3] https://commitfest.postgresql.org/patch/7351/

Best regards,
Mikhail.

Re: Crashes on a partition whose concurrent detach never finished

От:
Masahiko Sawada <sawada.mshk@gmail.com>
Дата:
On Sun, Sep 27, 2026 at 7:27 AM Mihail Nikalayeu
 wrote:
>
> Hello, everyone!
>
> Thanks to Amit for pushing, and to others for new findings and reviews.
>
> Attached is v2 of the remaining fixes, rebased on master and
> registered in the commitfest as [3] for tracking purposes.
>
> I tried to combine everything into the series. It is mostly
> AI-generated, but I still think structuring everything is helpful
> anyway.
>
> The rule throughout is that a partition pending detach is published as
> a standalone table, as it will be after FINALIZE; publishing it via
> the former root would cause the divergence Nisha described in [1].
>
> 0001 (pgoutput crash): The test comment Shveta asked about was
> misleading; it's fixed. pgindent-clean applied.
>
> 0002 (identity sequence) gains a new test: an insert into a leaf under
> a partition pending detach still finds the root's sequence.
>
> 0003 is Zsolt's fix for the inconsistency Shveta pointed out:
> pg_get_publication_tables() now lists a partition with no active
> ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.
>
> Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).
>
> The commit message now also says, as Nisha found in [2], that the full
> list has been affected since 14, while the targeted lookup only exists
> in 19.
>
> 0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
> It also invalidates the descendants of a partitioned partition, as
> Nisha suggested in [1], and locks them with AccessShareLock.

I ran into this issue today. I think it's not fixed on v19 yet and
should be added to the open item so as not to miss it.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com


Re: Crashes on a partition whose concurrent detach never finished

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Tue, Nov 10, 2026 at 12:40 AM Masahiko Sawada  wrote:
>
> On Sun, Sep 27, 2026 at 7:27 AM Mihail Nikalayeu
>  wrote:
> >
> > Hello, everyone!
> >
> > Thanks to Amit for pushing, and to others for new findings and reviews.
> >
> > Attached is v2 of the remaining fixes, rebased on master and
> > registered in the commitfest as [3] for tracking purposes.
> >
> > I tried to combine everything into the series. It is mostly
> > AI-generated, but I still think structuring everything is helpful
> > anyway.
> >
> > The rule throughout is that a partition pending detach is published as
> > a standalone table, as it will be after FINALIZE; publishing it via
> > the former root would cause the divergence Nisha described in [1].
> >
> > 0001 (pgoutput crash): The test comment Shveta asked about was
> > misleading; it's fixed. pgindent-clean applied.
> >
> > 0002 (identity sequence) gains a new test: an insert into a leaf under
> > a partition pending detach still finds the root's sequence.
> >
> > 0003 is Zsolt's fix for the inconsistency Shveta pointed out:
> > pg_get_publication_tables() now lists a partition with no active
> > ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.
> >
> > Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).
> >
> > The commit message now also says, as Nisha found in [2], that the full
> > list has been affected since 14, while the targeted lookup only exists
> > in 19.
> >
> > 0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
> > It also invalidates the descendants of a partitioned partition, as
> > Nisha suggested in [1], and locks them with AccessShareLock.
>
> I ran into this issue today. I think it's not fixed on v19 yet and
> should be added to the open item so as not to miss it.
>

Hi Sawada-san,

Could you please clarify which issue you are referring to here?

IIUC, the only open item for PG19 is the
is_table_publishable_in_publication() related issue, details shared in
point #2 at [1]. The patch v2-0003 shared by Mihail at [2] should
address this.

The other pending issue is the pgoutput crash, which is an existing
code issue (since pg14).

[1] https://www.postgresql.org/message-id/CABdArM7Bc7SZPSHk5uT-yA6%3DDYVFW-Os4noB6CANH6GQw9rvew%40mail.gmail.com
[2] https://www.postgresql.org/message-id/CADzfLwU97r3QC5oZDeVcWvcvXhNy9VnoFNDVHw%2BERg_DEG4%3DFQ%40mail.gmail.com

--
Thanks,
Nisha


Re: Crashes on a partition whose concurrent detach never finished

От:
Masahiko Sawada <sawada.mshk@gmail.com>
Дата:
On Mon, Nov 9, 2026 at 6:54 PM Nisha Moond  wrote:
>
> On Tue, Nov 10, 2026 at 12:40 AM Masahiko Sawada  wrote:
> >
> > On Sun, Sep 27, 2026 at 7:27 AM Mihail Nikalayeu
> >  wrote:
> > >
> > > Hello, everyone!
> > >
> > > Thanks to Amit for pushing, and to others for new findings and reviews.
> > >
> > > Attached is v2 of the remaining fixes, rebased on master and
> > > registered in the commitfest as [3] for tracking purposes.
> > >
> > > I tried to combine everything into the series. It is mostly
> > > AI-generated, but I still think structuring everything is helpful
> > > anyway.
> > >
> > > The rule throughout is that a partition pending detach is published as
> > > a standalone table, as it will be after FINALIZE; publishing it via
> > > the former root would cause the divergence Nisha described in [1].
> > >
> > > 0001 (pgoutput crash): The test comment Shveta asked about was
> > > misleading; it's fixed. pgindent-clean applied.
> > >
> > > 0002 (identity sequence) gains a new test: an insert into a leaf under
> > > a partition pending detach still finds the root's sequence.
> > >
> > > 0003 is Zsolt's fix for the inconsistency Shveta pointed out:
> > > pg_get_publication_tables() now lists a partition with no active
> > > ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.
> > >
> > > Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).
> > >
> > > The commit message now also says, as Nisha found in [2], that the full
> > > list has been affected since 14, while the targeted lookup only exists
> > > in 19.
> > >
> > > 0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
> > > It also invalidates the descendants of a partitioned partition, as
> > > Nisha suggested in [1], and locks them with AccessShareLock.
> >
> > I ran into this issue today. I think it's not fixed on v19 yet and
> > should be added to the open item so as not to miss it.
> >
>
> Hi Sawada-san,
>
> Could you please clarify which issue you are referring to here?
>
> IIUC, the only open item for PG19 is the
> is_table_publishable_in_publication() related issue, details shared in
> point #2 at [1]. The patch v2-0003 shared by Mihail at [2] should
> address this.
>
> The other pending issue is the pgoutput crash, which is an existing
> code issue (since pg14).

Sorry for not being clear. I meant the pgoutput crash.

IIUC while this is an existing issue, commit fd366065e06 made it
worse. Before the commit, the llast_oid() call on the result of
get_partition_ancestors() in get_rel_sync_entry() was reached only
when publish_via_partition_root = true, but now it's reached
regardless of publish_via_partition_root for FOR ALL TABLES
publications. So decoding a change to a detach-pending partition
crashes the walsender even with the default publish_via_partition_root
= false. In other words, that case works with v18 but no longer with
v19. So I think we should fix it in v19.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com


Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
Вложения:
On Wed, Nov 11, 2026 at 2:16 AM Masahiko Sawada  wrote:
>
> On Mon, Nov 9, 2026 at 6:54 PM Nisha Moond  wrote:
> >
> > On Tue, Nov 10, 2026 at 12:40 AM Masahiko Sawada  wrote:
> > >
> > > On Sun, Sep 27, 2026 at 7:27 AM Mihail Nikalayeu
> > >  wrote:
> > > >
> > > > Hello, everyone!
> > > >
> > > > Thanks to Amit for pushing, and to others for new findings and reviews.
> > > >
> > > > Attached is v2 of the remaining fixes, rebased on master and
> > > > registered in the commitfest as [3] for tracking purposes.
> > > >
> > > > I tried to combine everything into the series. It is mostly
> > > > AI-generated, but I still think structuring everything is helpful
> > > > anyway.
> > > >
> > > > The rule throughout is that a partition pending detach is published as
> > > > a standalone table, as it will be after FINALIZE; publishing it via
> > > > the former root would cause the divergence Nisha described in [1].
> > > >
> > > > 0001 (pgoutput crash): The test comment Shveta asked about was
> > > > misleading; it's fixed. pgindent-clean applied.
> > > >
> > > > 0002 (identity sequence) gains a new test: an insert into a leaf under
> > > > a partition pending detach still finds the root's sequence.
> > > >
> > > > 0003 is Zsolt's fix for the inconsistency Shveta pointed out:
> > > > pg_get_publication_tables() now lists a partition with no active
> > > > ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.
> > > >
> > > > Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).
> > > >
> > > > The commit message now also says, as Nisha found in [2], that the full
> > > > list has been affected since 14, while the targeted lookup only exists
> > > > in 19.
> > > >
> > > > 0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
> > > > It also invalidates the descendants of a partitioned partition, as
> > > > Nisha suggested in [1], and locks them with AccessShareLock.
> > >
> > > I ran into this issue today. I think it's not fixed on v19 yet and
> > > should be added to the open item so as not to miss it.
> > >
> >
> > Hi Sawada-san,
> >
> > Could you please clarify which issue you are referring to here?
> >
> > IIUC, the only open item for PG19 is the
> > is_table_publishable_in_publication() related issue, details shared in
> > point #2 at [1]. The patch v2-0003 shared by Mihail at [2] should
> > address this.
> >
> > The other pending issue is the pgoutput crash, which is an existing
> > code issue (since pg14).
>
> Sorry for not being clear. I meant the pgoutput crash.

Yes, I reproduced the crash on PG 19 using the attached test. I
verified that it works on PG18.

> IIUC while this is an existing issue, commit fd366065e06 made it
> worse. Before the commit, the llast_oid() call on the result of
> get_partition_ancestors() in get_rel_sync_entry() was reached only
> when publish_via_partition_root = true, but now it's reached
> regardless of publish_via_partition_root for FOR ALL TABLES
> publications. So decoding a change to a detach-pending partition
> crashes the walsender even with the default publish_via_partition_root
> = false. In other words, that case works with v18 but no longer with
> v19. So I think we should fix it in v19.
>
> Regards,
>
> --
> Masahiko Sawada
> Amazon Web Services: https://aws.amazon.com

Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
Вложения:
On Wed, Nov 11, 2026 at 10:51 AM shveta malik  wrote:
>
> On Wed, Nov 11, 2026 at 2:16 AM Masahiko Sawada  wrote:
> >
> > On Mon, Nov 9, 2026 at 6:54 PM Nisha Moond  wrote:
> > >
> > > On Tue, Nov 10, 2026 at 12:40 AM Masahiko Sawada  wrote:
> > > >
> > > > On Sun, Sep 27, 2026 at 7:27 AM Mihail Nikalayeu
> > > >  wrote:
> > > > >
> > > > > Hello, everyone!
> > > > >
> > > > > Thanks to Amit for pushing, and to others for new findings and reviews.
> > > > >
> > > > > Attached is v2 of the remaining fixes, rebased on master and
> > > > > registered in the commitfest as [3] for tracking purposes.
> > > > >
> > > > > I tried to combine everything into the series. It is mostly
> > > > > AI-generated, but I still think structuring everything is helpful
> > > > > anyway.
> > > > >
> > > > > The rule throughout is that a partition pending detach is published as
> > > > > a standalone table, as it will be after FINALIZE; publishing it via
> > > > > the former root would cause the divergence Nisha described in [1].
> > > > >
> > > > > 0001 (pgoutput crash): The test comment Shveta asked about was
> > > > > misleading; it's fixed. pgindent-clean applied.
> > > > >
> > > > > 0002 (identity sequence) gains a new test: an insert into a leaf under
> > > > > a partition pending detach still finds the root's sequence.
> > > > >
> > > > > 0003 is Zsolt's fix for the inconsistency Shveta pointed out:
> > > > > pg_get_publication_tables() now lists a partition with no active
> > > > > ancestors, so REFRESH PUBLICATION can pick it up before FINALIZE.
> > > > >
> > > > > Tests moved to 100_bugs.pl to reuse infra from 0001 (AI-generated).
> > > > >
> > > > > The commit message now also says, as Nisha found in [2], that the full
> > > > > list has been affected since 14, while the targeted lookup only exists
> > > > > in 19.
> > > > >
> > > > > 0004 is Shveta's invalidation, which I (mostly AI) finished up a bit.
> > > > > It also invalidates the descendants of a partitioned partition, as
> > > > > Nisha suggested in [1], and locks them with AccessShareLock.
> > > >
> > > > I ran into this issue today. I think it's not fixed on v19 yet and
> > > > should be added to the open item so as not to miss it.
> > > >
> > >
> > > Hi Sawada-san,
> > >
> > > Could you please clarify which issue you are referring to here?
> > >
> > > IIUC, the only open item for PG19 is the
> > > is_table_publishable_in_publication() related issue, details shared in
> > > point #2 at [1]. The patch v2-0003 shared by Mihail at [2] should
> > > address this.
> > >
> > > The other pending issue is the pgoutput crash, which is an existing
> > > code issue (since pg14).
> >
> > Sorry for not being clear. I meant the pgoutput crash.
>
> Yes, I reproduced the crash on PG 19 using the attached test. I
> verified that it works on PG18.
>
> > IIUC while this is an existing issue, commit fd366065e06 made it
> > worse. Before the commit, the llast_oid() call on the result of
> > get_partition_ancestors() in get_rel_sync_entry() was reached only
> > when publish_via_partition_root = true, but now it's reached
> > regardless of publish_via_partition_root for FOR ALL TABLES
> > publications. So decoding a change to a detach-pending partition
> > crashes the walsender even with the default publish_via_partition_root
> > = false. In other words, that case works with v18 but no longer with
> > v19. So I think we should fix it in v19.

I have attached a potential fix for Pg19. It is similar to the fix in
'RelationBuildPublicationDesc'. I have run a few related test-suits on
this; I have yet to run 'make check world'.

The issue reproduces on HEAD too; the same patch applies and fixes it there.

thanks
Shveta

Re: Crashes on a partition whose concurrent detach never finished

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 11:00 AM shveta malik  wrote:
>
> On Wed, Nov 11, 2026 at 10:51 AM shveta malik  wrote:
> >
> > > Sorry for not being clear. I meant the pgoutput crash.
> >
> > Yes, I reproduced the crash on PG 19 using the attached test. I
> > verified that it works on PG18.
> >
> > > IIUC while this is an existing issue, commit fd366065e06 made it
> > > worse. Before the commit, the llast_oid() call on the result of
> > > get_partition_ancestors() in get_rel_sync_entry() was reached only
> > > when publish_via_partition_root = true, but now it's reached
> > > regardless of publish_via_partition_root for FOR ALL TABLES
> > > publications. So decoding a change to a detach-pending partition
> > > crashes the walsender even with the default publish_via_partition_root
> > > = false. In other words, that case works with v18 but no longer with
> > > v19. So I think we should fix it in v19.
>
> I have attached a potential fix for Pg19. It is similar to the fix in
> 'RelationBuildPublicationDesc'. I have run a few related test-suits on
> this; I have yet to run 'make check world'.
>

I think this is mostly the same fix as v2-0001* in [1]. But the points
to consider are the fix is for both except and non-except cases, shall
we fix both if so, non-except should be ideally committed till PG-14.
Then the next question to consider is whether to fix the invalidation
problem you reported in [2]. Without the invalidation, the crash will
be fixed but probably the answer whether to replicate the partition
changes could be incorrect (this will be true for both EXCEPT and
non-EXCEPT cases).

I feel in any case the invalidation problem is not related to PG-19
code change and requires more discussion. So, we should leave that and
discuss whether to fix both EXCEPT and non-EXCEPT cases?

[1]: https://www.postgresql.org/message-id/CADzfLwU97r3QC5oZDeVcWvcvXhNy9VnoFNDVHw%2BERg_DEG4%3DFQ%40mail.gmail.com
[2]: https://www.postgresql.org/message-id/CAJpy0uA6womAP7fkmT%3DsSfKG_0CfKUSb7HhP_J9mw071MXc39w%40mail.gmail.com

-- 
With Regards,
Amit Kapila.


Re: Crashes on a partition whose concurrent detach never finished

От:
Zhijie Hou <houzhijie22@gmail.com>
Дата:
Вложения:
Hi,

On Sun, Sep27, 2026 at 10:26 PM Mihail Nikalayeu wrote:
> Attached is v2 of the remaining fixes, rebased on master and
> registered in the commitfest as [3] for tracking purposes.
>
> I tried to combine everything into the series. It is mostly
> AI-generated, but I still think structuring everything is helpful
> anyway.
>
> The rule throughout is that a partition pending detach is published as
> a standalone table, as it will be after FINALIZE; publishing it via
> the former root would cause the divergence Nisha described in [1].
>
> 0001 (pgoutput crash): The test comment Shveta asked about was
> misleading; it's fixed. pgindent-clean applied.

Since we are considering whether to push 0001 first, I reviewed it and 
have few suggestions:

1. We can remove the am_partition variable completely and simply check
"ancestors" in the subsequent code, to be consistent with 
RelationBuildPublicationDesc.

2. The test can be simplified to cover only the decoding crash (since 
the subscriber side is not touched by this patch), which saves buildfarm 
test time. In addition, we can move the test into the existing isolation 
test to speed it up further.

I have attached a top-up patch for 0001 with these changes. Feel free to 
merge it if it looks good.


-- 
Best Regards,
Zhijie Hou

Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 12:49 PM Amit Kapila  wrote:
>
> On Wed, Nov 11, 2026 at 11:00 AM shveta malik  wrote:
> >
> > On Wed, Nov 11, 2026 at 10:51 AM shveta malik  wrote:
> > >
> > > > Sorry for not being clear. I meant the pgoutput crash.
> > >
> > > Yes, I reproduced the crash on PG 19 using the attached test. I
> > > verified that it works on PG18.
> > >
> > > > IIUC while this is an existing issue, commit fd366065e06 made it
> > > > worse. Before the commit, the llast_oid() call on the result of
> > > > get_partition_ancestors() in get_rel_sync_entry() was reached only
> > > > when publish_via_partition_root = true, but now it's reached
> > > > regardless of publish_via_partition_root for FOR ALL TABLES
> > > > publications. So decoding a change to a detach-pending partition
> > > > crashes the walsender even with the default publish_via_partition_root
> > > > = false. In other words, that case works with v18 but no longer with
> > > > v19. So I think we should fix it in v19.
> >
> > I have attached a potential fix for Pg19. It is similar to the fix in
> > 'RelationBuildPublicationDesc'. I have run a few related test-suits on
> > this; I have yet to run 'make check world'.
> >
>
> I think this is mostly the same fix as v2-0001* in [1].

yes, it looks the same; we can take that patch.

> But the points
> to consider are the fix is for both except and non-except cases, shall
> we fix both if so, non-except should be ideally committed till PG-14.
> Then the next question to consider is whether to fix the invalidation
> problem you reported in [2]. Without the invalidation, the crash will
> be fixed but probably the answer whether to replicate the partition
> changes could be incorrect (this will be true for both EXCEPT and
> non-EXCEPT cases).
>
> I feel in any case the invalidation problem is not related to PG-19
> code change and requires more discussion. So, we should leave that and
> discuss whether to fix both EXCEPT and non-EXCEPT cases?

+1

For non-EXCEPT, I also think that fix will be needed till PG15. Not
sure about PG14, as it reaches end of life on 12 November 2026, which
is tomorrow as per [1].

[1]: https://www.postgresql.org/message-id/flat/026ae0e2-c107-4d1e-bb2f-48130a6ca883%40postgresql.org


>
> [1]: https://www.postgresql.org/message-id/CADzfLwU97r3QC5oZDeVcWvcvXhNy9VnoFNDVHw%2BERg_DEG4%3DFQ%40mail.gmail.com
> [2]: https://www.postgresql.org/message-id/CAJpy0uA6womAP7fkmT%3DsSfKG_0CfKUSb7HhP_J9mw071MXc39w%40mail.gmail.com
>
> --
> With Regards,
> Amit Kapila.


Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 1:05 PM Zhijie Hou  wrote:
>
> Hi,
>
> On Sun, Sep27, 2026 at 10:26 PM Mihail Nikalayeu wrote:
> > Attached is v2 of the remaining fixes, rebased on master and
> > registered in the commitfest as [3] for tracking purposes.
> >
> > I tried to combine everything into the series. It is mostly
> > AI-generated, but I still think structuring everything is helpful
> > anyway.
> >
> > The rule throughout is that a partition pending detach is published as
> > a standalone table, as it will be after FINALIZE; publishing it via
> > the former root would cause the divergence Nisha described in [1].
> >
> > 0001 (pgoutput crash): The test comment Shveta asked about was
> > misleading; it's fixed. pgindent-clean applied.
>
> Since we are considering whether to push 0001 first, I reviewed it and
> have few suggestions:
>
> 1. We can remove the am_partition variable completely and simply check
> "ancestors" in the subsequent code, to be consistent with
> RelationBuildPublicationDesc.
>
> 2. The test can be simplified to cover only the decoding crash (since
> the subscriber side is not touched by this patch), which saves buildfarm
> test time. In addition, we can move the test into the existing isolation
> test to speed it up further.
>
> I have attached a top-up patch for 0001 with these changes. Feel free to
> merge it if it looks good.

I agree with the changes. Few concerns:

It would be better to show in the additional steps that
pg_inherits.inhdetachpending is true before we actually try
pg_logical_slot_get_binary_changes.

Also I feel it would make more sense to create-pub with default
publish_via_partition_root rather than publish_via_partition_root=true
for PG19's testcase.

thanks
Shveta


Re: Crashes on a partition whose concurrent detach never finished

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 2:21 PM shveta malik  wrote:
>
> On Wed, Nov 11, 2026 at 12:49 PM Amit Kapila  wrote:
> >
>
> > But the points
> > to consider are the fix is for both except and non-except cases, shall
> > we fix both if so, non-except should be ideally committed till PG-14.
> > Then the next question to consider is whether to fix the invalidation
> > problem you reported in [2]. Without the invalidation, the crash will
> > be fixed but probably the answer whether to replicate the partition
> > changes could be incorrect (this will be true for both EXCEPT and
> > non-EXCEPT cases).
> >
> > I feel in any case the invalidation problem is not related to PG-19
> > code change and requires more discussion. So, we should leave that and
> > discuss whether to fix both EXCEPT and non-EXCEPT cases?
>
> +1
>
> For non-EXCEPT, I also think that fix will be needed till PG15. Not
> sure about PG14, as it reaches end of life on 12 November 2026, which
> is tomorrow as per [1].
>

Right, we need the fix to be backpatched till PG15. Sawada-San, let us
know if you think differently about the above plan (both the scope of
fix and till which version it should be fixed) for pursuing the fix?

-- 
With Regards,
Amit Kapila.


Re: Crashes on a partition whose concurrent detach never finished

От:
Zhijie Hou <houzhijie22@gmail.com>
Дата:
Вложения:
Hi,

On Wed, Nov11, 2026 at 05:06 PM shveta malik wrote:
> On Wed, Nov 11, 2026 at 1:05 PM Zhijie Hou  wrote:
> > Since we are considering whether to push 0001 first, I reviewed it
> > and have few suggestions:
> >
> > 1. We can remove the am_partition variable completely and simply check
> > "ancestors" in the subsequent code, to be consistent with
> > RelationBuildPublicationDesc.
> >
> > 2. The test can be simplified to cover only the decoding crash (since
> > the subscriber side is not touched by this patch), which saves
> > buildfarm test time. In addition, we can move the test into the
> > existing isolation test to speed it up further.
> >
> > I have attached a top-up patch for 0001 with these changes. Feel
> > free to merge it if it looks good.
>
> I agree with the changes. Few concerns:

Thanks for reviewing.

>
> It would be better to show in the additional steps that
> pg_inherits.inhdetachpending is true before we actually try
> pg_logical_slot_get_binary_changes.

I checked that no existing tests (either for DETACH CONCURRENTLY or 
otherwise) refer to the inhdetachpendin in their test cases, and since 
our test basically tests the DETACH behavior as well, I think it's fine 
to skip testing this.

>
> Also I feel it would make more sense to create-pub with default
> publish_via_partition_root rather than publish_via_partition_root=true
> for PG19's testcase.

Changed as suggested.

After some analysis, I think creating slots in src/test/isolation/ 
wouldn't be stable, since some buildfarm animals may run the main 
regression tests under wal_level=minimal. I also didn't find slot 
creation in the main isolation tests. So I chose to put the test in 
test_decoding/concurrent_ddl_dml.spec, which has precedent for creating 
slots with pgoutput under test_decoding tests, so it can be acceptable.

I'm helping to merge the changes into 0001 and preparing patches for all 
branches, hoping to close this item soon.

-- 
Best Regards,
Zhijie Hou

Re: Crashes on a partition whose concurrent detach never finished

От:
shveta malik <shveta.malik@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 8:04 PM Zhijie Hou  wrote:
>
> Hi,
>
> On Wed, Nov11, 2026 at 05:06 PM shveta malik wrote:
> > On Wed, Nov 11, 2026 at 1:05 PM Zhijie Hou  wrote:
> > > Since we are considering whether to push 0001 first, I reviewed it
> > > and have few suggestions:
> > >
> > > 1. We can remove the am_partition variable completely and simply check
> > > "ancestors" in the subsequent code, to be consistent with
> > > RelationBuildPublicationDesc.
> > >
> > > 2. The test can be simplified to cover only the decoding crash (since
> > > the subscriber side is not touched by this patch), which saves
> > > buildfarm test time. In addition, we can move the test into the
> > > existing isolation test to speed it up further.
> > >
> > > I have attached a top-up patch for 0001 with these changes. Feel
> > > free to merge it if it looks good.
> >
> > I agree with the changes. Few concerns:
>
> Thanks for reviewing.
>
> >
> > It would be better to show in the additional steps that
> > pg_inherits.inhdetachpending is true before we actually try
> > pg_logical_slot_get_binary_changes.
>
> I checked that no existing tests (either for DETACH CONCURRENTLY or
> otherwise) refer to the inhdetachpendin in their test cases, and since
> our test basically tests the DETACH behavior as well, I think it's fine
> to skip testing this.
>
> >
> > Also I feel it would make more sense to create-pub with default
> > publish_via_partition_root rather than publish_via_partition_root=true
> > for PG19's testcase.
>
> Changed as suggested.
>
> After some analysis, I think creating slots in src/test/isolation/
> wouldn't be stable, since some buildfarm animals may run the main
> regression tests under wal_level=minimal. I also didn't find slot
> creation in the main isolation tests. So I chose to put the test in
> test_decoding/concurrent_ddl_dml.spec, which has precedent for creating
> slots with pgoutput under test_decoding tests, so it can be acceptable.
>
> I'm helping to merge the changes into 0001 and preparing patches for all
> branches, hoping to close this item soon.
>

Overall, the patches look good to me. Just a nit: the name "pub" looks
very generic for a test spec shared by many permutations. Perhaps we
can name it "pub_test_detach" or "pub_detach".

thanks
Shveta


Re: Crashes on a partition whose concurrent detach never finished

От:
Zhijie Hou <houzhijie22@gmail.com>
Дата:
Hi,

On Thu, Nov12, 2026 at 12:44 PM shveta malik wrote:
> On Wed, Nov 11, 2026 at 8:04 PM Zhijie Hou  wrote:
> >
> > I'm helping to merge the changes into 0001 and preparing patches for
> > all branches, hoping to close this item soon.
> >
>
> Overall, the patches look good to me. Just a nit: the name "pub" looks
> very generic for a test spec shared by many permutations. Perhaps we
> can name it "pub_test_detach" or "pub_detach".

Thanks for reviewing.

Since there's only one publication in this file, I think the current 
name is fine as we don't need to distinguish it from any other 
publication. Similar names are also used in other tests.

-- 
Best Regards,
Zhijie Hou


Re: Crashes on a partition whose concurrent detach never finished

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
On Wed, Nov 11, 2026 at 8:04 PM Zhijie Hou  wrote:
>
> I'm helping to merge the changes into 0001 and preparing patches for all
> branches, hoping to close this item soon.
>

Thanks for the patches. The fix LGTM. I tested the patches on all
respective branches and found no issues.

--
Nisha


Re: Crashes on a partition whose concurrent detach never finished

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Thu, Nov 12, 2026 at 11:29 AM Nisha Moond  wrote:
>
> On Wed, Nov 11, 2026 at 8:04 PM Zhijie Hou  wrote:
> >
> > I'm helping to merge the changes into 0001 and preparing patches for all
> > branches, hoping to close this item soon.
> >
>
> Thanks for the patches. The fix LGTM. I tested the patches on all
> respective branches and found no issues.
>

Pushed.

-- 
With Regards,
Amit Kapila.


Re: Crashes on a partition whose concurrent detach never finished

От:
Alvaro Herrera <alvherre@alvh.no-ip.org>
Дата:
On 2026-Nov-12, Zhijie Hou wrote:

> Since there's only one publication in this file, I think the current name is
> fine as we don't need to distinguish it from any other publication. Similar
> names are also used in other tests.

Right now, isolation tests run one after the other, so you're right that
this name doesn't really matter much.  However, someday it might be nice
if we can make (some of) them run in parallel.  We tried to do that eons
ago, couldn't find the time to implement it, idea was forgotten.  If
that effort ever takes off again it would be nice if we don't have to
fix a thousand pointless name conflicts of this kind.  (We already have
enough of those that we'll have to fix.)  So I think Shveta had the
right idea here.

Anyway, thanks everybody for getting this fixed.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"The problem with the future is that it keeps turning into the present"
(Hobbes)


Re: Crashes on a partition whose concurrent detach never finished

От:
Amit Kapila <amit.kapila16@gmail.com>
Дата:
On Thu, Nov 12, 2026 at 4:40 PM Alvaro Herrera  wrote:
>
> On 2026-Nov-12, Zhijie Hou wrote:
>
> > Since there's only one publication in this file, I think the current name is
> > fine as we don't need to distinguish it from any other publication. Similar
> > names are also used in other tests.
>
> Right now, isolation tests run one after the other, so you're right that
> this name doesn't really matter much.  However, someday it might be nice
> if we can make (some of) them run in parallel.  We tried to do that eons
> ago, couldn't find the time to implement it, idea was forgotten.  If
> that effort ever takes off again it would be nice if we don't have to
> fix a thousand pointless name conflicts of this kind.  (We already have
> enough of those that we'll have to fix.)  So I think Shveta had the
> right idea here.
>

Fair enough, now that I have committed the patch, is it worth
considering to change the name in HEAD-only?

BTW, it will be helpful to get some feedback from you on the 0004
patch in email [1] as that directly touches the detach partition ...
concurrently code path. You might want to read the email [2] to
understand the issue 0004 patch is trying to solve.

[1]: https://www.postgresql.org/message-id/CADzfLwU97r3QC5oZDeVcWvcvXhNy9VnoFNDVHw%2BERg_DEG4%3DFQ%40mail.gmail.com
[2]: https://www.postgresql.org/message-id/CABdArM4fJ8JAWyP0MAF%3D8n66M6%3DCouUmtSGwqizn2pD%3DgfPEZw%40mail.gmail.com

-- 
With Regards,
Amit Kapila.


Re: Crashes on a partition whose concurrent detach never finished

От:
Nisha Moond <nisha.moond412@gmail.com>
Дата:
Вложения:
On Thu, Nov 12, 2026 at 1:42 PM Amit Kapila  wrote:
>
> On Thu, Nov 12, 2026 at 11:29 AM Nisha Moond  wrote:
> >
> > On Wed, Nov 11, 2026 at 8:04 PM Zhijie Hou  wrote:
> > >
> > > I'm helping to merge the changes into 0001 and preparing patches for all
> > > branches, hoping to close this item soon.
> > >
> >
> > Thanks for the patches. The fix LGTM. I tested the patches on all
> > respective branches and found no issues.
> >
>
> Pushed.
>

Here are the remaining patches rebased and updated as needed:
  v3-0001: Rebased only; no other changes.

  v3-0002: The code is unchanged. Its TAP test depended on the setup
in the old v2-0001 test in 100_bugs.pl, which was not committed (the
committed fix tests via test_decoding instead). I kept the parts it
needs and trimmed the rest to what this patch fixes. The checks of
what pgoutput sends are removed, as decoding is now covered by the
committed test.

  v3-0003: Rebased only; no other changes.

--
Thanks,
Nisha
FAQ