On Tue, May 18, 2021 at 11:46:25PM -0400, Tom Lane wrote:
> I was wondering if we could move the ExecCleanupTupleRouting call
> into finish_estate. copyfrom.c, for example, does that during
> its shutdown function. Compare also the worker.c changes proposed
> in
Yeah, the first patch I wrote for this thread was pushing out
PopActiveSnapshot() into the finish() routine, but I really found the
creation of the ModifyTableState stuff needed for a partitioned table
done in create_estate_for_relation() to make the code more confusing,
as that's only a piece needed for the tuple routing path. Saying
that, minimizing calls to PopActiveSnapshot() and PushActiveSnapshot()
is an improvement. That's why I settled into more calls to
AfterTriggerEndQuery() in the 4 code paths of any apply (tuple routing
+ 3 DMLs).
> https://www.postgresql.org/message-id/3362608.1621367104%40sss.pgh.pa.us
>
> which are because I discovered it's unsafe to pop the snapshot
> before running AfterTriggerEndQuery.
Didn't remember this one. This reminds me of something similar I did
a couple of weeks ago for the worker code, similar to what you have
here. Moving the snapshot push to be earlier, as your other patch is
doing, was bringing a bit more sanity when it came to opening the
indexes of the relation on which a change is applied as we need an
active snapshot for predicates and expressions (aka ExecOpenIndices
and ExecCloseIndices).
--
Michael