pgsql: pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth

Started by Robert Haas3 months ago3 messagescommitters
Jump to latest
#1Robert Haas
rhaas@postgresql.org

pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()

Without CHECK_FOR_INTERRUPTS(), backends might not respond to query
cancellations in a timely fashion, especially for JOIN_ORDER()
specifications, where matching against each join can take O(n^2) time
in the length of the join order list in degenerate cases.

Recursive functions should check_stack_depth().

Reported-by: Noah Misch <noah@leadboat.com>
Discussion: /messages/by-id/CA+TgmoYmXy-jiP5qDhqNEiYFEBzQsArO6O2d9E8szNZqi1bePQ@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1129570f654e96d45bbc63397079171af29710b9

Modified Files
--------------
contrib/pg_plan_advice/pgpa_ast.c | 14 ++++++++++++++
contrib/pg_plan_advice/pgpa_planner.c | 7 +++++++
contrib/pg_plan_advice/pgpa_trove.c | 3 +++
3 files changed, 24 insertions(+)

#2Nathan Bossart
nathandbossart@gmail.com
In reply to: Robert Haas (#1)
Re: pgsql: pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth

On Wed, Sep 09, 2026 at 10:39:46PM +0000, Robert Haas wrote:

pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()

koel is unhappy with this one:

https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=koel&dt=2026-09-10%2010%3A34%3A01

--
nathan

#3Robert Haas
robertmhaas@gmail.com
In reply to: Nathan Bossart (#2)
Re: pgsql: pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth

On Thu, Sep 10, 2026 at 1:41 PM Nathan Bossart <nathandbossart@gmail.com> wrote:

On Wed, Sep 09, 2026 at 10:39:46PM +0000, Robert Haas wrote:

pg_plan_advice: Add CHECK_FOR_INTERRUPTS() and check_stack_depth()

koel is unhappy with this one:

https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=koel&dt=2026-09-10%2010%3A34%3A01

Yeah, Bilal reported that to me earlier via Discord. Fix pushed now.
(I didn't see this email before pushing it.)

--
Robert Haas
EDB: http://www.enterprisedb.com