You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2025/03/20 15:30:02 UTC
(ignite) branch master updated: IGNITE-24800 SQL: Fix SQL plan logging failure for EXPLAIN queries - Fixes #11946.
This is an automated email from the ASF dual-hosted git repository.
alexpl 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 c743f417d02 IGNITE-24800 SQL: Fix SQL plan logging failure for EXPLAIN queries - Fixes #11946.
c743f417d02 is described below
commit c743f417d023f7b9608c3bac0ccc9608c50a40fe
Author: oleg-vlsk <ol...@yandex.ru>
AuthorDate: Thu Mar 20 18:28:37 2025 +0300
IGNITE-24800 SQL: Fix SQL plan logging failure for EXPLAIN queries - Fixes #11946.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../integration/SqlPlanHistoryIntegrationTest.java | 37 ++++++++++++++++++----
.../query/running/SqlPlanHistoryTracker.java | 2 +-
.../internal/processors/query/h2/H2QueryInfo.java | 7 ++--
3 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java
index 9984cf39ea2..179971ca7b6 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlPlanHistoryIntegrationTest.java
@@ -58,6 +58,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.apache.ignite.configuration.SqlConfiguration.DFLT_SQL_PLAN_HISTORY_SIZE;
+import static org.apache.ignite.internal.processors.performancestatistics.AbstractPerformanceStatisticsTest.startCollectStatistics;
import static org.apache.ignite.internal.processors.query.running.RunningQueryManager.SQL_PLAN_HIST_VIEW;
import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
import static org.junit.Assert.assertNotEquals;
@@ -133,19 +134,24 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
@Parameterized.Parameter(3)
public boolean isFullyFetched;
+ /** Flag indicating whether the collection of performance statistics is enabled. */
+ @Parameterized.Parameter(4)
+ public boolean isPerfStatsEnabled;
+
/**
* @return Test parameters.
*/
- @Parameterized.Parameters(name = "sqlEngine={0}, isClient={1} loc={2}, isFullyFetched={3}")
+ @Parameterized.Parameters(name = "sqlEngine={0}, isClient={1} loc={2}, isFullyFetched={3}, isPerfStatsEnabled={4}")
public static Collection<Object[]> params() {
return Arrays.stream(new Object[][]{
{CalciteQueryEngineConfiguration.ENGINE_NAME},
{IndexingQueryEngineConfiguration.ENGINE_NAME}
}).flatMap(sqlEngine -> Arrays.stream(sqlEngine[0].equals(IndexingQueryEngineConfiguration.ENGINE_NAME) ?
- new Boolean[]{false} : new Boolean[]{true, false})
- .flatMap(isClient -> Arrays.stream(isClient ? new Boolean[]{false} : new Boolean[]{true, false})
- .flatMap(loc -> Arrays.stream(new Boolean[]{true, false})
- .map(isFullyFetched -> new Object[]{sqlEngine[0], isClient, loc, isFullyFetched})))
+ new Boolean[]{false} : new Boolean[]{true, false})
+ .flatMap(isClient -> Arrays.stream(isClient ? new Boolean[]{false} : new Boolean[]{true, false})
+ .flatMap(loc -> Arrays.stream(new Boolean[]{true, false})
+ .flatMap(isFullyFetched -> Arrays.stream(new Boolean[]{true, false})
+ .map(isPerfStatsEnabled -> new Object[]{sqlEngine[0], isClient, loc, isFullyFetched, isPerfStatsEnabled}))))
).collect(Collectors.toList());
}
@@ -214,6 +220,9 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
if (isClient)
startClientGrid(1);
+ if (isPerfStatsEnabled)
+ startCollectStatistics();
+
IgniteCache<Integer, String> cacheA = queryNode().cache("A");
IgniteCache<Integer, String> cacheB = queryNode().cache("B");
@@ -331,6 +340,12 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
runFailedQuery(new SqlQuery<>("String", "from String where fail()=1"));
}
+ /** Checks that EXPLAIN queries execute successfully and are not added to the SQL plan history. */
+ @Test
+ public void testExplainQuery() throws Exception {
+ runQueryWithoutPlan(new SqlFieldsQuery("explain plan for " + SQL));
+ }
+
/** Checks ScanQuery. */
@Test
public void testScanQuery() throws Exception {
@@ -370,6 +385,8 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
/** Checks that older plan entries are evicted when maximum history size is reached. */
@Test
public void testPlanHistoryEviction() throws Exception {
+ assumeFalse(isPerfStatsEnabled);
+
startTestGrid();
IgniteCache<Integer, String> cache = queryNode().cache("A");
@@ -402,6 +419,8 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
*/
@Test
public void testEntryReplacement() throws Exception {
+ assumeFalse(isPerfStatsEnabled);
+
startTestGrid();
long firstTs;
@@ -494,6 +513,8 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
assumeTrue("ScanCount suffix can only be present in H2 local query plans",
sqlEngine == IndexingQueryEngineConfiguration.ENGINE_NAME && loc);
+ assumeFalse(isPerfStatsEnabled);
+
startTestGrid();
final int iterations = 5;
@@ -729,6 +750,8 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
* @param reset Reset event.
*/
public void checkReset(Runnable reset) throws Exception {
+ assumeFalse(isPerfStatsEnabled);
+
startTestGrid();
IgniteCache<Integer, String> cache = queryNode().cache("A");
@@ -756,6 +779,8 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
* @param startGridFirst Flag indicating whether to start the grid before the setup.
*/
public void checkEmptyHistory(Runnable setup, boolean startGridFirst) throws Exception {
+ assumeFalse(isPerfStatsEnabled);
+
if (startGridFirst)
startTestGrid();
@@ -784,7 +809,7 @@ public class SqlPlanHistoryIntegrationTest extends GridCommonAbstractTest {
if (isSingleEngineCheck)
assumeFalse(sqlEngine == CalciteQueryEngineConfiguration.ENGINE_NAME);
- assumeFalse(isClient || loc || isFullyFetched);
+ assumeFalse(isClient || loc || isFullyFetched || isPerfStatsEnabled);
startTestGrid();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/SqlPlanHistoryTracker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/SqlPlanHistoryTracker.java
index 70a77804b7f..905f5cf6d79 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/SqlPlanHistoryTracker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/running/SqlPlanHistoryTracker.java
@@ -45,7 +45,7 @@ public class SqlPlanHistoryTracker {
* @param engine SQL engine.
*/
public void addPlan(String plan, String qry, String schema, boolean loc, String engine) {
- if (sqlPlanHistory == EMPTY_MAP)
+ if (sqlPlanHistory == EMPTY_MAP || plan.isEmpty())
return;
SqlPlan sqlPlan = new SqlPlan(plan, qry, schema, loc, engine);
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java
index 0bccf8134ba..53d720326a2 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2QueryInfo.java
@@ -121,8 +121,11 @@ public class H2QueryInfo implements TrackableQuery {
/** */
public synchronized String plan() {
- if (plan == null)
- plan = planWithoutScanCount(stmt.getPlanSQL());
+ if (plan == null) {
+ String plan0 = stmt.getPlanSQL();
+
+ plan = (plan0 != null) ? planWithoutScanCount(plan0) : "";
+ }
return plan;
}