korlov42 commented on code in PR #4827: URL: https://github.com/apache/ignite-3/pull/4827#discussion_r1871125433
########## modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImplTest.java: ########## @@ -1081,6 +1041,70 @@ public void timeoutFiredOnInitialization() throws Throwable { } } + @Test + void executionsWithTheSameQueryIdMustNotInterfere() { + QueryPlan plan = prepare("SELECT * FROM test_tbl", operationContext(null).build()); + + String expectedExceptionMessage = "This is expected"; + + TestNode corruptedNode = testCluster.node(nodeNames.get(2)); + corruptedNode.interceptor((nodeName, msg, original) -> { + if (msg instanceof QueryBatchRequestMessage) { + corruptedNode.messageService().send(nodeName, new SqlQueryMessagesFactory().errorMessage() + .queryId(((QueryBatchRequestMessage) msg).queryId()) + .executionToken(((QueryBatchRequestMessage) msg).executionToken()) + .fragmentId(((QueryBatchRequestMessage) msg).fragmentId()) + .message(expectedExceptionMessage) + .traceId(((QueryBatchRequestMessage) msg).queryId()) + .code(Common.INTERNAL_ERR) + .build() + ); + } else { + original.onMessage(nodeName, msg); + } + + return nullCompletedFuture(); + }); + + SqlOperationContext ctx = operationContext(null).build(); + + Queue<Throwable> exceptions = new ConcurrentLinkedQueue<>(); + BiFunction<AsyncDataCursor<InternalSqlRow>, Integer, CompletableFuture<Void>> retryChainBuilder = new BiFunction<>() { + @Override + public CompletableFuture<Void> apply( + @Nullable AsyncDataCursor<InternalSqlRow> cursor, Integer remainingAttempts + ) { + CompletableFuture<Void> previousStep; + if (cursor == null) { + previousStep = nullCompletedFuture(); + } else { + previousStep = cursor.onFirstPageReady() + .thenCompose(none -> cursor.onClose()) + .exceptionally(ex -> { + exceptions.add(ex); + + return null; + }); + } + + if (remainingAttempts > 0) { + return previousStep + .thenCompose(ignored -> executionServices.get(0).executePlan(plan, ctx)) + .thenCompose(c -> this.apply(c, remainingAttempts - 1)); + } + + return previousStep; + } + }; + + int retryCount = 20; + await(retryChainBuilder.apply(null, retryCount)); + Review Comment: good catch, thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org