Revert "IGNITE-19628 Add IndexQuery to performance statistics"
This reverts commit 9eaae91e0a54bd984db542354d190643d56d2b0d.
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/QueryRegistryImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/QueryRegistryImpl.java
index d023a25..01929ab 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/QueryRegistryImpl.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/QueryRegistryImpl.java
@@ -65,6 +65,8 @@
long locId = qryMgr.register(rootQry.sql(), GridCacheQueryType.SQL_FIELDS, rootQry.context().schemaName(),
false, createCancelToken(qry), initiatorId, false, false, false);
+ qryMgr.trackRequestId(locId);
+
rootQry.localQueryId(locId);
return qry;
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryFuture.java
index 2042fd4..46ba4fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryFuture.java
@@ -41,8 +41,6 @@
import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX;
-import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL;
-import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT;
/**
@@ -70,9 +68,6 @@
/** Metadata for IndexQuery. */
private final CompletableFuture<IndexQueryResultMeta> idxQryMetaFut;
- /** Query start time in nanoseconds to measure duration. */
- private final long startTimeNanos;
-
/**
* @param ctx Cache context.
* @param reqId Request ID.
@@ -114,8 +109,6 @@
reducer = qry.query().type() == TEXT ? new TextQueryReducer<>(streamsMap) : new UnsortedCacheQueryReducer<>(streamsMap);
}
-
- startTimeNanos = ctx.kernalContext().performanceStatistics().enabled() ? System.nanoTime() : 0;
}
/**
@@ -246,8 +239,6 @@
* Send initial query request to query nodes.
*/
public void startQuery() {
- if (cctx.kernalContext().performanceStatistics().enabled())
-
try {
GridCacheQueryRequest req = GridCacheQueryRequest.startQueryRequest(cctx, reqId, this);
@@ -324,41 +315,4 @@
firstPageLatch.countDown();
}
}
-
- /** {@inheritDoc} */
- @Override public boolean onDone(Collection<R> res, Throwable err) {
- assert qry.query().type() != SQL_FIELDS;
- assert qry.query().type() != SQL;
-
- if (cctx.kernalContext().performanceStatistics().enabled() && startTimeNanos > 0) {
- GridCacheQueryType type = qry.query().type();
-
- String text;
-
- switch (type) {
- case SCAN:
- text = cctx.name();
-
- break;
-
- case INDEX:
- text = cctx.name() + ":" + qry.query().idxQryDesc().toString();
-
- break;
-
- default:
- text = cctx.name();
- }
-
- cctx.kernalContext().performanceStatistics().query(
- qry.query().type(),
- text,
- reqId,
- startTimeNanos,
- System.nanoTime() - startTimeNanos,
- err == null);
- }
-
- return super.onDone(res, err);
- }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
index ecae75e..f7b3f7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
@@ -650,13 +650,23 @@
if (fut != null)
fut.cancel();
- if (performanceStatsEnabled && (logicalReads > 0 || physicalReads > 0)) {
- cctx.kernalContext().performanceStatistics().queryReads(
+ if (performanceStatsEnabled) {
+ cctx.kernalContext().performanceStatistics().query(
SCAN,
- cctx.localNodeId(),
+ cctx.name(),
((GridCacheDistributedQueryFuture)fut).requestId(),
- logicalReads,
- physicalReads);
+ startTime,
+ System.nanoTime() - startTimeNanos,
+ true);
+
+ if (logicalReads > 0 || physicalReads > 0) {
+ cctx.kernalContext().performanceStatistics().queryReads(
+ SCAN,
+ cctx.localNodeId(),
+ ((GridCacheDistributedQueryFuture)fut).requestId(),
+ logicalReads,
+ physicalReads);
+ }
}
}
};
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index b3a8f62..72c6633 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -70,7 +70,6 @@
import org.apache.ignite.plugin.security.SecurityPermission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.INDEX;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SCAN;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SET;
@@ -577,8 +576,6 @@
boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(cctx.localNodeId());
- assert type != SQL_FIELDS;
-
if (type == SQL_FIELDS || type == SPI)
return (CacheQueryFuture<R>)(loc ? qryMgr.queryFieldsLocal(bean) :
qryMgr.queryFieldsDistributed(bean, nodes));
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
index 65686bc..9272395 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridRunningQueryInfo.java
@@ -74,6 +74,9 @@
/** Distributed joins flag. */
private final boolean distributedJoins;
+ /** Request ID. */
+ private long reqId;
+
/** Subject ID. */
private final UUID subjId;
@@ -229,6 +232,11 @@
return span;
}
+ /** @return Request ID. */
+ public long requestId() {
+ return reqId;
+ }
+
/**
* @return Query's originator string (client host+port, user name,
* job name or any user's information about query initiator).
@@ -258,6 +266,11 @@
return lazy;
}
+ /** @param reqId Request ID. */
+ public void requestId(long reqId) {
+ this.reqId = reqId;
+ }
+
/** @return Subject ID. */
public UUID subjectId() {
return subjId;
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/RunningQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/RunningQueryManager.java
index 013f053..c98bf4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/RunningQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/RunningQueryManager.java
@@ -130,6 +130,9 @@
/** Logger. */
private final IgniteLogger log;
+ /** Current running query info. */
+ private final ThreadLocal<GridRunningQueryInfo> currQryInfo = new ThreadLocal<>();
+
/** */
private final ReadWriteLock lock = new ReentrantReadWriteLock();
@@ -273,6 +276,9 @@
GridRunningQueryInfo preRun = runs.putIfAbsent(qryId, run);
+ if (ctx.performanceStatistics().enabled())
+ currQryInfo.set(run);
+
assert preRun == null : "Running query already registered [prev_qry=" + preRun + ", newQry=" + run + ']';
run.span().addTag(SQL_QRY_ID, run::globalQueryId);
@@ -399,7 +405,7 @@
ctx.performanceStatistics().query(
qry.queryType(),
qry.query(),
- qry.id(),
+ qry.requestId(),
qry.startTime(),
System.nanoTime() - qry.startTimeNanos(),
!failed);
@@ -410,6 +416,16 @@
}
}
+ /** @param reqId Request ID of query to track. */
+ public void trackRequestId(long reqId) {
+ if (ctx.performanceStatistics().enabled()) {
+ GridRunningQueryInfo info = currQryInfo.get();
+
+ if (info != null)
+ info.requestId(reqId);
+ }
+ }
+
/**
* Return SQL queries which executing right now.
*
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 18bb7ab..27f2b72 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -602,7 +602,7 @@
ctx.performanceStatistics().queryReads(
GridCacheQueryType.SQL_FIELDS,
node.id(),
- qryId,
+ reqId,
stat.logicalReads(),
stat.physicalReads());
}
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 0a56fb3..bd14af3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -97,7 +97,6 @@
import org.h2.value.Value;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SQL_RETRY_TIMEOUT;
@@ -427,6 +426,8 @@
final long qryReqId = qryReqIdGen.incrementAndGet();
+ h2.runningQueryManager().trackRequestId(qryReqId);
+
boolean release = true;
try {
@@ -935,6 +936,8 @@
final long reqId = qryReqIdGen.incrementAndGet();
+ h2.runningQueryManager().trackRequestId(reqId);
+
final DmlDistributedUpdateRun r = new DmlDistributedUpdateRun(nodes.size());
int flags = enforceJoinOrder ? GridH2QueryRequest.FLAG_ENFORCE_JOIN_ORDER : 0;