Re: Consistent segfault in complex query
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Kyle Samson <kysamson@tripadvisor.com>,
"pgsql-hackers\@postgresql.org" <pgsql-hackers@postgresql.org>,
Matthew Kelly <mkelly@tripadvisor.com>
Date: 2018-09-14T19:55:40Z
Lists: pgsql-hackers
Attachments
- 0001-epq-initplan-fix-1.patch (text/x-diff) patch 0001
- 0002-remove-ExecEvalParamExecParams-1.patch (text/x-diff) patch 0002
Andrew Gierth <andrew@tao11.riddles.org.uk> writes: > If it helps, here is a patch that adds isolation tests to > eval-plan-qual.spec for two test cases (one with CTE, one without). > I've verified that these reproduce the crash, and that they run > successfully with your patch. I can't currently see any more specific > code paths to probe in these tests. Thanks! I incorporated these into the attached proposed patches. The main difference from what I had yesterday is that I rewrote ExecEvalParamExecParams to my satisfaction. The crucial thing I didn't like about it was that it hard-wired use of the GetPerTupleExprContext econtext for initplan evaluation. That seemed like it risked memory leaks in case of repeated initplan evaluation for a single top-level output tuple. I've since convinced myself that it's basically impossible to leak memory in ExecSetParamPlan right now (cf comments below), but that doesn't seem like an assumption to bake into an API when it isn't even buying us anything to do so. The attached is split into two parts because 0001 will need to go all the way back, whereas 0002 only applies to HEAD and v11. I don't plan to make them separate commits though. A quick test says that back-patching 0001 might be slightly painful; a lot of the hunks don't apply. I've not looked at why not. regards, tom lane
Commits
-
Fix failure with initplans used conditionally during EvalPlanQual rechecks.
- f13e2d1cec9b 11.0 landed
- 9b14bbd52c8c 9.5.15 landed
- 99cbbbbd1ddd 10.6 landed
- 8494755109e9 9.4.20 landed
- 591d0ac8858c 9.3.25 landed
- 2a97a0ad34da 9.6.11 landed
- 1f4a920b7309 12.0 landed