Re: Bypassing cursors in postgres_fdw to enable parallel plans

From: "Yilin Zhang" <jiezhilove(at)126(dot)com>
To: "Rafia Sabih" <rafia(dot)pghackers(at)gmail(dot)com>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "KENAN YILMAZ" <kenan(dot)yilmaz(at)localus(dot)com(dot)tr>, "Andy Fan" <zhihuifan1213(at)163(dot)com>, "PostgreSQL Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bypassing cursors in postgres_fdw to enable parallel plans
Date: 2026-07-16 06:53:55
Message-ID: 40be12af.473c.19f69b40cb4.Coremail.jiezhilove@126.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 2026-07-15 11:50:32,"Rafia Sabih" <rafia(dot)pghackers(at)gmail(dot)com> wrote
> Hello Yilin,
> Thanks for your input. But unfortunately I am not able to reproduce the
> issue with this test case. Also, I am not able to understand it much, as to
> how we are going to access bug2_pid from session 2, because it is a temp
> table from a different session. Maybe you can simplify this a little more,
> or maybe share the backtrace in case of the crash.

> Yes you are right, this was the gap, in case of crash while draining,
> active_fsstate couldn't be cleared and a dangling pointer was left, which
> causes the crash on the next execution.
> To fix this, I have now added a condition in pgfdw_abort_cleanup, to reset
> the active_scan in case of unfinished drain. Since I was not able to use
> your test case so I couldn't verify if this fixes the issue.
> Apart from that I have now changed the save_to_tuplestore function to only
> have active_fsstate and PGconn. Also, there is a wrapper function to call
> it and check the relevant condition so we don't duplicate it all those 5
> places. I have also added the calls to function to drain tuples to
> tuplestore in execute_dml_stmt and exectute_foreign_modify, to ensure that
> whenever a new query is sent on the connection, we perform the draining of
> the tuples to tuplestore if any or mark the other scan completed
> appropriately.

Sorry, that was my mistake.
The temp keyword in the "CREATE TEMP TABLE" statement is unnecessary; just remove it directly.
This crash has already been fixed in the v13 patch.
LGTM.

Best regards,

--

Yilin Zhang

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message solai v 2026-07-16 07:08:05 Re: [BUG] Take a long time to reach consistent after pg_rewind
Previous Message Zhijie Hou (Fujitsu) 2026-07-16 06:31:05 RE: walsummarizer can get stuck when switching timelines