[COMMITTERS] pgsql: Separate reinitialization of shared parallel-scan state fromExe - Mailing list pgsql-committers

From Tom Lane
Subject [COMMITTERS] pgsql: Separate reinitialization of shared parallel-scan state fromExe
Date
Msg-id E1dn6dK-0000BJ-6l@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d6a149f4e6a1243ccae6e1817050da9e84050b2a

Modified Files
--------------
doc/src/sgml/custom-scan.sgml             | 29 ++++++++---
doc/src/sgml/fdwhandler.sgml              | 43 +++++++++++-----
src/backend/access/heap/heapam.c          | 38 +++++++-------
src/backend/executor/execParallel.c       | 85 ++++++++++++++++++++++++++-----
src/backend/executor/nodeBitmapHeapscan.c | 42 ++++++++-------
src/backend/executor/nodeCustom.c         | 15 ++++++
src/backend/executor/nodeForeignscan.c    | 23 ++++++++-
src/backend/executor/nodeGather.c         | 29 ++++++-----
src/backend/executor/nodeGatherMerge.c    | 29 ++++++-----
src/backend/executor/nodeIndexonlyscan.c  | 29 +++++------
src/backend/executor/nodeIndexscan.c      | 38 ++++++--------
src/backend/executor/nodeSeqscan.c        | 16 ++++++
src/include/access/heapam.h               |  1 +
src/include/executor/execParallel.h       |  3 +-
src/include/executor/nodeBitmapHeapscan.h |  2 +
src/include/executor/nodeCustom.h         |  2 +
src/include/executor/nodeForeignscan.h    |  2 +
src/include/executor/nodeIndexonlyscan.h  |  2 +
src/include/executor/nodeIndexscan.h      |  1 +
src/include/executor/nodeSeqscan.h        |  1 +
src/include/foreign/fdwapi.h              |  4 ++
src/include/nodes/extensible.h            |  3 ++
22 files changed, 302 insertions(+), 135 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: [COMMITTERS] pgsql: Restore test case froma2b70c89ca1a5fcf6181d3c777d82e7b83d2de1b.
Next
From: Tom Lane
Date:
Subject: [COMMITTERS] pgsql: Code review for nodeGatherMerge.c.