未验证 提交 abb1032d 编写于 作者: D Denis Smirnov 提交者: GitHub

Init gpmon packet for dynamic scan states (#10046)

Dynamic scans use scan states to initialize and keep sidecar nodes.
It is done bypassing ExecInitNode that normally does gpmon packet
initialization. As a result gpmon is not initialized for all
dynamic sidecar nodes that causes "bad magic 0" warnings.
上级 d5685b9f
......@@ -122,6 +122,10 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node)
if (node->ss.ps.instrument)
InstrStopNode(node->ss.ps.instrument, 1 /* nTuples */);
/* Increment gpmon packet too */
if (&node->ss.ps.gpmon_pkt)
Gpmon_Incr_Rows_Out(&node->ss.ps.gpmon_pkt);
return (Node *) bitmap;
}
......
......@@ -112,6 +112,7 @@ initNextTableToScan(DynamicBitmapHeapScanState *node)
Oid currentPartitionOid;
Oid *pid;
Relation currentRelation;
PlanState *bhsPlanState;
pid = hash_seq_search(&node->pidStatus);
if (pid == NULL)
......@@ -177,6 +178,16 @@ initNextTableToScan(DynamicBitmapHeapScanState *node)
node->bhsState = ExecInitBitmapHeapScanForPartition(&plan->bitmapheapscan, estate, node->eflags,
currentRelation);
/*
* Setup gpmon counters for BitmapHeapScan. Rows count for sidecar partition scan should
* be consistent with a parent dynamic scan as they share the same plan_node_id. Otherwise
* partition sends zero row number while dynamic scan sends an actual value and this is
* confusing.
*/
bhsPlanState = &node->bhsState->ss.ps;
InitPlanNodeGpmonPkt(bhsPlanState->plan, &bhsPlanState->gpmon_pkt, estate);
bhsPlanState->gpmon_pkt.u.qexec.rowsout = node->ss.ps.gpmon_pkt.u.qexec.rowsout;
/*
* Rescan the child node, and attach it to the sidecar BitmapHeapScan.
*/
......@@ -248,7 +259,16 @@ ExecDynamicBitmapHeapScan(DynamicBitmapHeapScanState *node)
slot = ExecBitmapHeapScan(node->bhsState);
if (!TupIsNull(slot))
{
/*
* Increment sidecar's partition scan tuples count.
* It should be incremented consistently with a
* dynamic scan to avoid gpperfmon anomalies.
*/
if (&node->bhsState->ss.ps.gpmon_pkt)
Gpmon_Incr_Rows_Out(&node->bhsState->ss.ps.gpmon_pkt);
break;
}
/* No more tuples from this partition. Move to next one. */
CleanupOnePartition(node);
......
......@@ -115,6 +115,7 @@ beginCurrentBitmapIndexScan(DynamicBitmapIndexScanState *node, EState *estate,
Relation currentRelation;
Oid indexOid;
MemoryContext oldCxt;
PlanState *bisPlanState;
oldCxt = MemoryContextSwitchTo(node->partitionMemoryContext);
......@@ -151,6 +152,16 @@ beginCurrentBitmapIndexScan(DynamicBitmapIndexScanState *node, EState *estate,
estate,
node->eflags);
/*
* Setup gpmon counters for BitmapIndexScan. Bitmaps count for sidecar index scan
* should be consistent with a parent dynamic scan as they share the same plan_node_id.
* Otherwise index sends zero bitmap number while dynamic scan sends an actual value
* and this is confusing.
*/
bisPlanState = &node->bitmapIndexScanState->ss.ps;
InitPlanNodeGpmonPkt(bisPlanState->plan, &bisPlanState->gpmon_pkt, estate);
bisPlanState->gpmon_pkt.u.qexec.rowsout = node->ss.ps.gpmon_pkt.u.qexec.rowsout;
if (node->ss.ps.instrument)
{
/* Let the BitmapIndexScan share our Instrument node */
......@@ -184,6 +195,7 @@ MultiExecDynamicBitmapIndexScan(DynamicBitmapIndexScanState *node)
{
EState *estate = node->ss.ps.state;
Oid tableOid;
Node *bitmap = NULL;
/* close previously open scan, if any. */
endCurrentBitmapIndexScan(node);
......@@ -205,7 +217,17 @@ MultiExecDynamicBitmapIndexScan(DynamicBitmapIndexScanState *node)
*/
beginCurrentBitmapIndexScan(node, estate, tableOid);
return MultiExecBitmapIndexScan(node->bitmapIndexScanState);
bitmap = MultiExecBitmapIndexScan(node->bitmapIndexScanState);
/*
* Increment dynamic index scan bitmap count.
* It should be incremented consistently with a
* sidecar index scan to avoid gpperfmon anomalies.
*/
if (&node->ss.ps.gpmon_pkt)
Gpmon_Incr_Rows_Out(&node->ss.ps.gpmon_pkt);
return bitmap;
}
/*
......
......@@ -141,6 +141,7 @@ beginCurrentIndexScan(DynamicIndexScanState *node, EState *estate,
Oid indexOid;
List *save_tupletable;
MemoryContext oldCxt;
PlanState *isPlanState;
/*
* open the base relation and acquire appropriate lock on it.
......@@ -173,6 +174,17 @@ beginCurrentIndexScan(DynamicIndexScanState *node, EState *estate,
node->indexScanState = ExecInitIndexScanForPartition(&dynamicIndexScan->indexscan, estate,
node->eflags,
currentRelation, indexOid);
/*
* Setup gpmon counters for IndexScan. Rows count for sidecar index scan should
* be consistent with a parent dynamic scan as they share the same plan_node_id.
* Otherwise index sends zero row number while dynamic scan sends an actual value
* and this is confusing.
*/
isPlanState = &node->indexScanState->ss.ps;
InitPlanNodeGpmonPkt(isPlanState->plan, &isPlanState->gpmon_pkt, estate);
isPlanState->gpmon_pkt.u.qexec.rowsout = node->ss.ps.gpmon_pkt.u.qexec.rowsout;
/* The IndexScan node takes ownership of currentRelation, and will close it when done */
node->tuptable = estate->es_tupleTable;
estate->es_tupleTable = save_tupletable;
......@@ -292,6 +304,14 @@ ExecDynamicIndexScan(DynamicIndexScanState *node)
{
slot = ExecIndexScan(node->indexScanState);
/*
* Increment sidecar's index scan tuples count.
* It should be incremented consistently with a
* dynamic scan to avoid gpperfmon anomalies.
*/
if (&node->indexScanState->ss.ps.gpmon_pkt)
Gpmon_Incr_Rows_Out(&node->indexScanState->ss.ps.gpmon_pkt);
if (TupIsNull(slot))
{
endCurrentIndexScan(node);
......
......@@ -105,6 +105,7 @@ initNextTableToScan(DynamicSeqScanState *node)
AttrNumber *attMap;
Oid *pid;
Relation currentRelation;
PlanState *ssPlanState;
pid = hash_seq_search(&node->pidStatus);
if (pid == NULL)
......@@ -168,6 +169,17 @@ initNextTableToScan(DynamicSeqScanState *node)
DynamicScan_SetTableOid(&node->ss, *pid);
node->seqScanState = ExecInitSeqScanForPartition(&plan->seqscan, estate, node->eflags,
currentRelation);
/*
* Setup gpmon counters for SeqScan. Rows count for sidecar partition scan should
* be consistent with a parent dynamic scan as they share the same plan_node_id.
* Otherwise partition sends zero row number while dynamic scan sends an actual
* value and this is confusing.
*/
ssPlanState = &node->seqScanState->ss.ps;
InitPlanNodeGpmonPkt(ssPlanState->plan, &ssPlanState->gpmon_pkt, estate);
ssPlanState->gpmon_pkt.u.qexec.rowsout = node->ss.ps.gpmon_pkt.u.qexec.rowsout;
return true;
}
......@@ -232,7 +244,16 @@ ExecDynamicSeqScan(DynamicSeqScanState *node)
slot = ExecSeqScan(node->seqScanState);
if (!TupIsNull(slot))
{
/*
* Increment sidecar's partition scan tuples count.
* It should be incremented consistently with a
* dynamic scan to avoid gpperfmon anomalies.
*/
if (&node->seqScanState->ss.ps.gpmon_pkt)
Gpmon_Incr_Rows_Out(&node->seqScanState->ss.ps.gpmon_pkt);
break;
}
/* No more tuples from this partition. Move to next one. */
CleanupOnePartition(node);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册