Re: partition routing layering in nodeModifyTable.c
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Amit Langote <amitlangote09@gmail.com>,
Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Daniel Gustafsson <daniel@yesql.se>,
Etsuro Fujita <etsuro.fujita@gmail.com>, Andres Freund <andres@anarazel.de>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-10-23T06:39:16Z
Lists: pgsql-hackers
On 23/10/2020 05:56, Amit Langote wrote: > On Thu, Oct 22, 2020 at 11:25 PM Alvaro Herrera <alvherre@alvh.no-ip.org> wrote: >> >> On 2020-Oct-22, Amit Langote wrote: >> >>> 0001 fixes a thinko of the recent commit 1375422c782 that I discovered >>> when debugging a problem with 0003. >> >> Hmm, how hard is it to produce a test case that fails because of this >> problem? > > I checked and don't think there's any live bug here. You will notice > if you take a look at 1375422c7 that we've made es_result_relations an > array of pointers while the individual ModifyTableState nodes own the > actual ResultRelInfos. So, EvalPlanQualStart() setting the parent > EState's es_result_relations array to NULL implies that those pointers > become inaccessible to the parent query's execution after > EvalPlanQual() returns. However, nothing in the tree today accesses > ResulRelInfos through es_result_relations array, except during > ExecInit* stage (see ExecInitForeignScan()) but it would still be > intact at that stage. > > With the lazy-initialization patch though, we do check > es_result_relations when trying to open a result relation to see if it > has already been initialized (a non-NULL pointer in that array means > yes), so resetting it in the middle of the execution can't be safe. > For one example, we will end up initializing the same relation many > times after not finding it in es_result_relations and also add it > *duplicatively* to es_opened_result_relations list, breaking the > invariant that that list contains distinct relations. Pushed that thinko-fix, thanks! - Heikki
Commits
-
Fix initialization of es_result_relations in EvalPlanQualStart().
- 22b73d3cb0b5 14.0 landed
-
Remove PartitionRoutingInfo struct.
- fb5883da8615 14.0 landed
-
Revise child-to-root tuple conversion map management.
- 6973533650c0 14.0 landed
-
Clean up code to resolve the "root target relation" in nodeModifyTable.c
- f49b85d783f6 14.0 landed
-
Refactor code for cross-partition updates to a separate function.
- c5b097f8fa69 14.0 landed
-
Remove es_result_relation_info from EState.
- a04daa97a433 14.0 landed
-
Include result relation info in direct modify ForeignScan nodes.
- 178f2d560dde 14.0 landed
-
Create ResultRelInfos later in InitPlan, index them by RT index.
- 1375422c7826 14.0 landed