mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-06 21:37:29 +08:00
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
34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* nodeSort.h
|
|
*
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/executor/nodeSort.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef NODESORT_H
|
|
#define NODESORT_H
|
|
|
|
#include "access/parallel.h"
|
|
#include "nodes/execnodes.h"
|
|
|
|
extern SortState *ExecInitSort(Sort *node, EState *estate, int eflags);
|
|
extern void ExecEndSort(SortState *node);
|
|
extern void ExecSortMarkPos(SortState *node);
|
|
extern void ExecSortRestrPos(SortState *node);
|
|
extern void ExecReScanSort(SortState *node);
|
|
|
|
/* parallel instrumentation support */
|
|
extern void ExecSortEstimate(SortState *node, ParallelContext *pcxt);
|
|
extern void ExecSortInitializeDSM(SortState *node, ParallelContext *pcxt);
|
|
extern void ExecSortReInitializeDSM(SortState *node, ParallelContext *pcxt);
|
|
extern void ExecSortInitializeWorker(SortState *node, shm_toc *toc);
|
|
extern void ExecSortRetrieveInstrumentation(SortState *node);
|
|
|
|
#endif /* NODESORT_H */
|