This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 6d022194ed3 Revert "IGNITE-19628 Add IndexQuery to performance
statistics"
6d022194ed3 is described below
commit 6d022194ed3f1c0007839204a481982f4614dd25
Author: NSAmelchev <[email protected]>
AuthorDate: Thu Jun 1 20:23:21 2023 +0300
Revert "IGNITE-19628 Add IndexQuery to performance statistics"
This reverts commit 9eaae91e0a54bd984db542354d190643d56d2b0d.
---
.../query/calcite/QueryRegistryImpl.java | 2 +
.../query/GridCacheDistributedQueryFuture.java | 46 ----------------------
.../query/GridCacheDistributedQueryManager.java | 20 +++++++---
.../cache/query/GridCacheQueryAdapter.java | 3 --
.../processors/query/GridRunningQueryInfo.java | 13 ++++++
.../processors/query/RunningQueryManager.java | 18 ++++++++-
.../query/h2/twostep/GridMapQueryExecutor.java | 2 +-
.../query/h2/twostep/GridReduceQueryExecutor.java | 5 ++-
8 files changed, 52 insertions(+), 57 deletions(-)
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 d023a258e1a..01929aba1e4 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 @@ public class QueryRegistryImpl extends AbstractService
implements QueryRegistry
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 2042fd40e47..46ba4fbce17 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.lang.GridPlainCallable;
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 @@ public class GridCacheDistributedQueryFuture<K, V, R> extends
GridCacheQueryFutu
/** 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 @@ public class GridCacheDistributedQueryFuture<K, V, R>
extends GridCacheQueryFutu
reducer = qry.query().type() == TEXT ? new
TextQueryReducer<>(streamsMap) : new UnsortedCacheQueryReducer<>(streamsMap);
}
-
- startTimeNanos = ctx.kernalContext().performanceStatistics().enabled()
? System.nanoTime() : 0;
}
/**
@@ -246,8 +239,6 @@ public class GridCacheDistributedQueryFuture<K, V, R>
extends GridCacheQueryFutu
* 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 @@ public class GridCacheDistributedQueryFuture<K, V, R>
extends GridCacheQueryFutu
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 ecae75e15f4..f7b3f7a8b8f 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 @@ public class GridCacheDistributedQueryManager<K, V>
extends GridCacheQueryManage
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 b3a8f62f7b1..72c663327fb 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.lang.IgniteReducer;
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 @@ public class GridCacheQueryAdapter<T> implements
CacheQuery<T> {
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 65686bcf213..927239533cc 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 @@ public class GridRunningQueryInfo {
/** Distributed joins flag. */
private final boolean distributedJoins;
+ /** Request ID. */
+ private long reqId;
+
/** Subject ID. */
private final UUID subjId;
@@ -229,6 +232,11 @@ public class GridRunningQueryInfo {
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 @@ public class GridRunningQueryInfo {
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 013f0538c6e..c98bf4cf87c 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 @@ public class RunningQueryManager {
/** 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 @@ public class RunningQueryManager {
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 @@ public class RunningQueryManager {
ctx.performanceStatistics().query(
qry.queryType(),
qry.query(),
- qry.id(),
+ qry.requestId(),
qry.startTime(),
System.nanoTime() - qry.startTimeNanos(),
!failed);
@@ -410,6 +416,16 @@ public class RunningQueryManager {
}
}
+ /** @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 18bb7abb412..27f2b72e324 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 @@ public class GridMapQueryExecutor {
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 0a56fb32b60..bd14af32c44 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.util.IntArray;
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 @@ public class GridReduceQueryExecutor {
final long qryReqId = qryReqIdGen.incrementAndGet();
+ h2.runningQueryManager().trackRequestId(qryReqId);
+
boolean release = true;
try {
@@ -935,6 +936,8 @@ public class GridReduceQueryExecutor {
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;