| From: | Hristos Nenkov <nenkov2004(at)gmail(dot)com> |
|---|---|
| To: | Lukas Fittl <lukas(at)fittl(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org, idrissaajalloh(at)gmail(dot)com |
| Subject: | Re: [PATCH] auto_explain: preserve per-query sampling decisions (#19877) |
| Date: | 2026-11-14 23:32:38 |
| Message-ID: | CAO7_G+yyWL-HCMPuA__fxXkVhEo220NbuQ0Ewp9crDwVLdU5Qg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Lukas,
Thanks for taking a look. I haven't encountered this in a real
application; I reproduced the reported behavior with targeted tests. I
don't have an end-user case to add, so I'm happy to leave it here
unless someone can confirm a practical impact.
Is there an existing bug or patch needing testing or review where I
could be more useful? I'd be glad to help.
Thanks,
Hristos
On Sat, 14 Nov 2026 12:50:41 -0800, Lukas Fittl <lukas(at)fittl(dot)com> wrote:
> Hi,
>
> On Sat, Nov 14, 2026 at 10:49 AM Hristos Nenkov <nenkov2004(at)gmail(dot)com> wrote:
> > I reproduced #19877 and attached a candidate fix for review.
> >
> > auto_explain currently checks its backend-global sampling flag again at
> > ExecutorEnd. A statement executed while a cursor remains open can replace
> > that flag, so a sampled cursor loses its plan. With pg_stat_statements
> > requesting instrumentation, the reverse also happens: an unsampled cursor
> > can be logged after another statement enables sampling.
> >
> > The patch records selection and nesting depth in auto_explain's own
> > QueryDesc extension state, following the existing pg_stat_statements
> > pattern. ExecutorEnd uses that state rather than the latest global flag.
> > It also adds cursor tests for explicit CLOSE and implicit COMMIT, with
> > pg_stat_statements preloaded.
>
> I think the patch approach could be workable - but is this really a
> problem in practice?
>
> We've gotten a lot of bug reports recently that fit the category of
> "LLM found an edge case and reported it", and when I saw this one
> first I did not think this was a real world problem.
>
> Adding more code carries maintenance cost, and I think it should be
> justified by an actual end user report running into this problem.
>
> Have you seen this problem yourself in practice?
>
> Thanks,
> Lukas
>
> --
> Lukas Fittl
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-11-14 23:33:22 | Re: two statement_timeout race conditions |
| Previous Message | Zsolt Parragi | 2026-11-14 23:06:35 | Re: two statement_timeout race conditions |