MCPcopy Create free account
hub / github.com/apache/cloudberry / mppExecutorWait

Function mppExecutorWait

src/backend/executor/execUtils.c:2085–2166  ·  view source on GitHub ↗

* QD wait for QEs to finish and check their results. */

Source from the content-addressed store, hash-verified

2083 * QD wait for QEs to finish and check their results.
2084 */
2085uint64 mppExecutorWait(QueryDesc *queryDesc)
2086{
2087 EState *estate;
2088 ExecSlice *currentSlice;
2089 int primaryWriterSliceIndex;
2090 uint64 es_processed = 0;
2091
2092 /* caller must have switched into per-query memory context already */
2093 estate = queryDesc->estate;
2094
2095 currentSlice = getCurrentSlice(estate, LocallyExecutingSliceIndex(estate));
2096 primaryWriterSliceIndex = PrimaryWriterSliceIndex(estate);
2097
2098 /*
2099 * If QD, wait for QEs to finish and check their results.
2100 */
2101 if (estate->dispatcherState && estate->dispatcherState->primaryResults)
2102 {
2103 CdbDispatchResults *pr = NULL;
2104 CdbDispatcherState *ds = estate->dispatcherState;
2105 DispatchWaitMode waitMode = DISPATCH_WAIT_NONE;
2106 ErrorData *qeError = NULL;
2107
2108 /*
2109 * If we are finishing a query before all the tuples of the query
2110 * plan were fetched we must call ExecSquelchNode before checking
2111 * the dispatch results in order to tell the nodes below we no longer
2112 * need any more tuples.
2113 */
2114 if (!estate->es_got_eos)
2115 {
2116 ExecSquelchNode(queryDesc->planstate, true);
2117 }
2118
2119 /*
2120 * Wait for completion of all QEs. We send a "graceful" query
2121 * finish, not cancel signal. Since the query has succeeded,
2122 * don't confuse QEs by sending erroneous message.
2123 */
2124 if (estate->cancelUnfinished)
2125 waitMode = DISPATCH_WAIT_FINISH;
2126
2127 cdbdisp_checkDispatchResult(ds, waitMode);
2128
2129 pr = cdbdisp_getDispatchResults(ds, &qeError);
2130
2131 if (qeError)
2132 {
2133 FlushErrorState();
2134 ReThrowError(qeError);
2135 }
2136
2137 if (ProcessDispatchResult_hook)
2138 ProcessDispatchResult_hook(ds);
2139
2140 /* collect pgstat from QEs for current transaction level */
2141 pgstat_combine_from_qe(pr, primaryWriterSliceIndex);
2142

Callers 1

standard_ExecutorRunFunction · 0.85

Calls 13

getCurrentSliceFunction · 0.85
PrimaryWriterSliceIndexFunction · 0.85
ExecSquelchNodeFunction · 0.85
ReThrowErrorFunction · 0.85
pgstat_combine_from_qeFunction · 0.85
cdbexplain_recvExecStatsFunction · 0.85
cdbdisp_sumCmdTuplesFunction · 0.85
cdbdisp_sumRejectedRowsFunction · 0.85

Tested by

no test coverage detected