Re: BUG #15577: Query returns different results when executed multiple times
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>,
David Rowley <david.rowley@2ndquadrant.com>,
Bartosz Polnik <bartoszpolnik@gmail.com>,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-01-10T17:38:13Z
Lists: pgsql-bugs
Attachments
- remove-NLP-slot-sharing-poc.patch (text/x-diff) patch
I wrote: > Well, if we posit that the problems are limited to false Param-sharing, > my inclination is to fix it by simplifying rather than adding complexity. > To wit, let's just assign a new PARAM_EXEC slot for every NestLoopParam > and never try to share them. The argument that sharing them would work > for NLPs representing the same Var hinged on the assumption that nested > NestLoops would necessarily execute "in sync", which we now see is false > at least when Gathers are in between. Here's a POC patch for that. It's seriously ugly, but it passes check-world and I can no longer reproduce the problem using mockup_bug15577_v2.sql. At this point assign_nestloop_param_var and assign_nestloop_param_placeholdervar are dead code, and there's a bunch of incorrect comments in subselect.c, and I really need to refactor the division of labor between createplan.c and subselect.c (for one thing, this is an abuse of the documented purpose of SS_make_initplan_output_param). But functionally I think it does the right thing. Please test and verify that you no longer see the race condition. regards, tom lane
Commits
-
Avoid sharing PARAM_EXEC slots between different levels of NestLoop.
- 2977a312df71 10.7 landed
- 05eb923eae46 11.2 landed
- 1db5667bac63 12.0 landed
- 4f80974990dc 9.6.12 landed