diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java index f0207a65a1d33..19fbeadb46396 100644 --- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java +++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java @@ -980,7 +980,10 @@ private void onMessage(UUID nodeId, final QueryStartRequest msg) { U.error(log, "Error occurred during send error message: " + X.getFullStackTrace(e)); } finally { - qryReg.query(msg.queryId()).onError(ex); + Query qry = qryReg.query(msg.queryId()); + + if (qry != null) + qry.onError(ex); } } } diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java index c57f4ff77b565..da4dfdd1d87c2 100644 --- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java +++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/CancelTest.java @@ -142,8 +142,12 @@ public void testNotOriginatorNodeStop() throws Exception { // Sometimes remote node during stopping can send error to originator node and this error processed before // node left event, in this case exception stack will looks like: // IgniteSQLException -> RemoteException -> exception on remote node during node stop. + // Also, remote node can be stopped during processing of QueryStartRequest, in this case QueryCloseRequest + // with an error will be sent to originator node, this causes query cancelation with an IgniteSQLException. if (!X.hasCause(ex, "node left", ClusterTopologyCheckedException.class) && - !X.hasCause(ex, RemoteException.class)) { + !X.hasCause(ex, RemoteException.class) && + !X.hasCause(ex, "The query was cancelled while executing", IgniteSQLException.class) + ) { log.error("Unexpected exception", ex); fail("Unexpected exception: " + ex);