]> granicus.if.org Git - postgresql/commit
Separate reinitialization of shared parallel-scan state from ExecReScan.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Aug 2017 17:18:16 +0000 (13:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Aug 2017 17:18:16 +0000 (13:18 -0400)
commit41b0dd987d44089dc48e9c70024277e253b396b7
treec42eeeb2f175764a9b1ad9c095f8a46057078eb3
parent6c2c5bea3cec4c874d1ee225bb6e222055c03d75
Separate reinitialization of shared parallel-scan state from ExecReScan.

Previously, the parallel executor logic did reinitialization of shared
state within the ExecReScan code for parallel-aware scan nodes.  This is
problematic, because it means that the ExecReScan call has to occur
synchronously (ie, during the parent Gather node's ReScan call).  That is
swimming very much against the tide so far as the ExecReScan machinery is
concerned; the fact that it works at all today depends on a lot of fragile
assumptions, such as that no plan node between Gather and a parallel-aware
scan node is parameterized.  Another objection is that because ExecReScan
might be called in workers as well as the leader, hacky extra tests are
needed in some places to prevent unwanted shared-state resets.

Hence, let's separate this code into two functions, a ReInitializeDSM
call and the ReScan call proper.  ReInitializeDSM is called only in
the leader and is guaranteed to run before we start new workers.
ReScan is returned to its traditional function of resetting only local
state, which means that ExecReScan's usual habits of delaying or
eliminating child rescan calls are safe again.

As with the preceding commit 7df2c1f8d, it doesn't seem to be necessary
to make these changes in 9.6, which is a good thing because the FDW and
CustomScan APIs are impacted.

Discussion: https://postgr.es/m/CAA4eK1JkByysFJNh9M349u_nNjqETuEnY_y1VUc_kJiU0bxtaQ@mail.gmail.com
24 files changed:
doc/src/sgml/custom-scan.sgml
doc/src/sgml/fdwhandler.sgml
src/backend/access/heap/heapam.c
src/backend/executor/execParallel.c
src/backend/executor/nodeBitmapHeapscan.c
src/backend/executor/nodeCustom.c
src/backend/executor/nodeForeignscan.c
src/backend/executor/nodeGather.c
src/backend/executor/nodeGatherMerge.c
src/backend/executor/nodeIndexonlyscan.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeSeqscan.c
src/backend/executor/nodeSort.c
src/include/access/heapam.h
src/include/executor/execParallel.h
src/include/executor/nodeBitmapHeapscan.h
src/include/executor/nodeCustom.h
src/include/executor/nodeForeignscan.h
src/include/executor/nodeIndexonlyscan.h
src/include/executor/nodeIndexscan.h
src/include/executor/nodeSeqscan.h
src/include/executor/nodeSort.h
src/include/foreign/fdwapi.h
src/include/nodes/extensible.h