Understanding ExecShutdownNode()

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Understanding ExecShutdownNode()
Date: 2025-08-11 11:13:19
Message-ID: df6f85fe-aaee-48b9-8c85-9fb28fa2b021@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

I'm working on a CSP and started wondering about the semantics of
ExecShutdownNode(). The documentation suggests that it can be used for
freeing resources early. Early meaning as soon as it's known that no
more rows need to be produced. For that, ExecutePlan() calls
ExecShutdownNode(), once all tuples got produced and no backscan is
possible.

However, reading through the code it seems to me that the function got
introduced for the purpose of being able to cleanup resources before the
DSM segment is removed. I cannot see how it could safely be used for
other purposes: ExecutePlan() calls ExecShutdownNode() even though
ExecutePlan() is possibly called again, e.g. when a cursor is used.

It looks like the existing code only works because parallelism is
disabled for all cases where ExecutePlan() might be invoked multiple
times (e.g. user cursors).

Can someone please shed some light on the intended use case? I'm
planning to conserve any learnings from this thread in src/executor/README.

--
David Geier

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2025-08-11 11:24:48 Obsolete comments in ResultRelInfo struct
Previous Message Fabrice Chapuis 2025-08-11 10:27:28 incremental backup