2015-09-29 03:55:57 +02:00
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
* execParallel.h
|
|
|
|
* POSTGRES parallel execution interface
|
|
|
|
*
|
2024-01-04 02:49:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
|
2015-09-29 03:55:57 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
|
|
|
* src/include/executor/execParallel.h
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EXECPARALLEL_H
|
|
|
|
#define EXECPARALLEL_H
|
|
|
|
|
|
|
|
#include "access/parallel.h"
|
|
|
|
#include "nodes/execnodes.h"
|
|
|
|
#include "nodes/parsenodes.h"
|
|
|
|
#include "nodes/plannodes.h"
|
2016-12-19 22:47:15 +01:00
|
|
|
#include "utils/dsa.h"
|
2015-09-29 03:55:57 +02:00
|
|
|
|
|
|
|
typedef struct SharedExecutorInstrumentation SharedExecutorInstrumentation;
|
|
|
|
|
|
|
|
typedef struct ParallelExecutorInfo
|
|
|
|
{
|
2017-09-01 23:38:54 +02:00
|
|
|
PlanState *planstate; /* plan subtree we're running in parallel */
|
|
|
|
ParallelContext *pcxt; /* parallel context we're using */
|
|
|
|
BufferUsage *buffer_usage; /* points to bufusage area in DSM */
|
2020-04-04 06:32:08 +02:00
|
|
|
WalUsage *wal_usage; /* walusage area in DSM */
|
2017-09-01 23:38:54 +02:00
|
|
|
SharedExecutorInstrumentation *instrumentation; /* optional */
|
2018-09-25 21:54:29 +02:00
|
|
|
struct SharedJitInstrumentation *jit_instrumentation; /* optional */
|
2017-09-01 23:38:54 +02:00
|
|
|
dsa_area *area; /* points to DSA area in DSM */
|
2017-11-16 18:06:14 +01:00
|
|
|
dsa_pointer param_exec; /* serialized PARAM_EXEC parameters */
|
2017-09-01 23:38:54 +02:00
|
|
|
bool finished; /* set true by ExecParallelFinish */
|
|
|
|
/* These two arrays have pcxt->nworkers_launched entries: */
|
|
|
|
shm_mq_handle **tqueue; /* tuple queues for worker output */
|
|
|
|
struct TupleQueueReader **reader; /* tuple reader/writer support */
|
2015-09-29 03:55:57 +02:00
|
|
|
} ParallelExecutorInfo;
|
|
|
|
|
|
|
|
extern ParallelExecutorInfo *ExecInitParallelPlan(PlanState *planstate,
|
2022-09-20 04:18:36 +02:00
|
|
|
EState *estate, Bitmapset *sendParams, int nworkers,
|
2017-11-16 18:06:14 +01:00
|
|
|
int64 tuples_needed);
|
2017-09-15 04:59:02 +02:00
|
|
|
extern void ExecParallelCreateReaders(ParallelExecutorInfo *pei);
|
2015-09-29 03:55:57 +02:00
|
|
|
extern void ExecParallelFinish(ParallelExecutorInfo *pei);
|
2015-10-16 17:56:02 +02:00
|
|
|
extern void ExecParallelCleanup(ParallelExecutorInfo *pei);
|
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
2017-08-30 19:18:16 +02:00
|
|
|
extern void ExecParallelReinitialize(PlanState *planstate,
|
2022-09-20 04:18:36 +02:00
|
|
|
ParallelExecutorInfo *pei, Bitmapset *sendParams);
|
2015-09-29 03:55:57 +02:00
|
|
|
|
2017-04-15 05:50:16 +02:00
|
|
|
extern void ParallelQueryMain(dsm_segment *seg, shm_toc *toc);
|
|
|
|
|
2015-09-29 03:55:57 +02:00
|
|
|
#endif /* EXECPARALLEL_H */
|