Re: BUG #19026: ResourceOwnerForget can't find owner for invalid plancache
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: Kirill Reshke <reshkekirill@gmail.com>, exclusion@gmail.com,
pgsql-bugs@lists.postgresql.org
Date: 2025-08-20T16:57:21Z
Lists: pgsql-bugs
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix re-execution of a failed SQLFunctionCache entry.
- a67d4847a431 19 (unreleased) landed
- 906b68217a1e 18.0 landed
Attachments
- bug-19026-alternative-3.patch (text/x-diff) patch
I wrote: > In practice, fcache->cplan will never be not-null after successful > completion of a SQL function, so one idea is to simply clear it > unconditionally as soon as we know we're starting a fresh execution, > more or less as in alternative-1 attached. However that leaves me > a bit unsatisfied, because it doesn't protect against the case of > erroring out of a set-returning function: if we come in and see > eslist != NULL, we'll pick right back up attempting to execute > plans that probably aren't there anymore. I think that that case > is unreachable today because we don't allow any opclass support > functions to be SRFs, and AFAIK there are no other cases where an > FmgrInfo would be re-used after a failed query. Still, I'm inclined > to go with something more like alternative-2, which feels a little > more future-proof. After closer inspection: Alexander's test case doesn't expose the full scope of the problem. If the function suffers an error at run-time rather than early in setup, then we will fall out with fcache->eslist being non-null as well as fcache->cplan. Then on the next call, init_sql_fcache will believe that it is resuming execution of a set-returning function, and we'll merrily try to execute an executor state tree that's not there anymore. So we have to do something more like my alternative-2 than any of the other proposals, and after reviewing the code I believe it had better reset the tstore and shutdown_reg fields as well. Hence, v3 attached, now with regression test case. regards, tom lane