Re: Restrict publishing of partitioned table with a foreign table as partition - Mailing list pgsql-hackers

From Shlok Kyal
Subject Re: Restrict publishing of partitioned table with a foreign table as partition
Date
Msg-id CANhcyEW0QMiJXMqpPFRHni-q0Rm4R0hpZ0LdaqA=F3wvDUU6sQ@mail.gmail.com
Whole thread Raw
In response to Re: Restrict publishing of partitioned table with a foreign table as partition  (Álvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: Restrict publishing of partitioned table with a foreign table as partition
List pgsql-hackers
On Mon, 7 Apr 2025 at 18:09, Álvaro Herrera <alvherre@alvh.no-ip.org> wrote:
>
> Here's the additional changes I made here before giving up on this.
> I think it needs some additional rethinking, not going to happen for 18.
>

Hi Alvaro,

Thanks for reviewing the patch.

The changes shared by you in [1], look good to me and I have added it
to the latest patch.
I have also included the changes shared by you in [2].
I have also addressed the issue reported by Sergey in [3].
Additionally, I made some changes to the comments, commit message and
documentation to reflect the changes in the function name and to
reduce the usage of 'foreign partition' term.

I saw some comments by you in the patches:
1.
+ /*
+ * Keep lock till end of transaction: must prevent this table from
+ * being attached a foreign table until we're done.  XXX does this
+ * prevent addition of a partition in a partitioned child?
+ */

This is same as the issue reported by Sergey in [3]. I have addressed
the issue in the latest patch. So, I have modified this comment.

2.
+ * We also take a ShareLock on pg_partitioned_table to restrict addition
+ * of new partitioned table which may contain a foreign partition while
+ * publication is being created.   XXX this is quite weird actually.

This change was added to resolve the concurrency issue shared by
Vignesh in [4]. I tried with different locks and found that lock with
severity >= ShareLock was needed to avoid the concurrency issue.
Initially I added ShareLock to pg_class, but to reduce the scope I
added it to pg_partitioned_table instead. I cannot think of an
alternate approach. Do you have any suggestions for this?

[1]: https://www.postgresql.org/message-id/202504062027.tqmabk2h353o%40alvherre.pgsql
[2]: https://www.postgresql.org/message-id/202504071239.kuj6m5a5wqxg%40alvherre.pgsql
[3]: https://www.postgresql.org/message-id/c64352fa-9a30-4e0a-853a-a6b5b6d07f4e%40postgrespro.ru
[4]: https://www.postgresql.org/message-id/CALDaNm2%2BeL22Sbvj74uS37xvt%3DhaQWcOwP15QnDuVeYsjHiffw%40mail.gmail.com

Thanks and Regards,
Shlok Kyal

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: allow changing autovacuum_max_workers without restarting
Next
From: Shlok Kyal
Date:
Subject: Re: Restrict publishing of partitioned table with a foreign table as partition