| From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
|---|---|
| To: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Fix race condition in pg_get_publication_tables with concurrent DROP TABLE |
| Date: | 2026-04-24 20:20:56 |
| Message-ID: | CALj2ACVSE1Ni5gU2FwGL5iTM3tm+Thv3oGJ-8MD=ySsbzzTX=Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Fri, Apr 24, 2026 at 12:17 AM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> > What about introducing a publication_tables_state struct stored in user_fctx
> > that carries both the list and a private position index? (kind of what
> > pg_timezone_abbrevs_zone() is doing).
>
> Yeah, that is a good idea. Seems doable.
+1. Thanks for the pointer. Adding a new struct to carry both the
table_infos and the current index into it seems simple with a smaller
diff.
If I were to think of another approach (I don't prefer this approach
anyway), we could convert pg_get_publication_tables from the current
value-per-call SRF function (SRF_IS_FIRSTCALL + SRF_RETURN_NEXT) to a
materialized SRF function (InitMaterializedSRF +
tuplestore_putvalues). With a materialized SRF function, there is no
need to add a new structure or maintain per-call context - table_infos
becomes a local variable, and we skip placing anything related to
dropped tables into the tuplestore immediately in the second loop (the
first loop remains the same, preparing the table_infos list). This
approach seems more complex with a larger diff and requires use of
InitMaterializedSRF for versions >= PG16, SetSingleFuncCall for PG15,
and for PG14 requires inlining SetSingleFuncCall.
I prefer adding the new struct to carry both table_infos and the
current index into it with the current value-per-call SRF function,
unless others have better ideas. If okay, I will send a new patch
soon. Thank you!
--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Jeff Davis | 2026-04-24 19:30:09 | Re: GUC parameter ACLs and physical walsender |