[To dev/1.3] Fix kill query doesn't take effect bug#17358
[To dev/1.3] Fix kill query doesn't take effect bug#17358JackieTien97 merged 5 commits intodev/1.3from
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev/1.3 #17358 +/- ##
==========================================
Coverage 41.36% 41.37%
Complexity 227 227
==========================================
Files 3594 3594
Lines 236637 236603 -34
Branches 28641 28631 -10
==========================================
- Hits 97891 97887 -4
+ Misses 138746 138716 -30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves DataNode query lifecycle management to ensure killed/missing queries are handled deterministically, resource cleanup is more robust, and query execution time metrics better reflect per-RPC behavior (especially around fetchResults).
Changes:
- Extend
IQueryExecutionwith per-RPC timing (updateCurrentRpcStartTime) and updateQueryExecution/ConfigExecutionimplementations accordingly. - Refactor query cleanup: remove
stopAndCleanup()overload, adjustCoordinator.cleanupQueryExecution()to remove executions from the map earlier, and add stale-query cleanup driven fromFragmentInstanceManager. - Improve
fetchResults/fetchResultsV2behavior when a query execution is missing (e.g., killed/cleaned up), returning an explicit error status instead of a “successful but empty” response.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeSortOperatorTest.java | Updates test stub to satisfy new IQueryExecution interface and removes removed API usage. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java | Adds per-RPC timing tracking fields/methods for config queries. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java | Adds per-RPC timing and adjusts cancellation/cleanup interactions with Coordinator. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java | Removes stopAndCleanup() overload and adds updateCurrentRpcStartTime. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java | Changes cleanup ordering (remove from map first) and adds stale-query cleanup. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java | Invokes coordinator stale-query cleanup on the existing timeout-cancel path. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java | Improves missing-query handling in fetch RPCs and wires per-RPC start time updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...re/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
Show resolved
Hide resolved
...re/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
Show resolved
Hide resolved
...re/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
Show resolved
Hide resolved
...re/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java
Show resolved
Hide resolved
...re/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java
Outdated
Show resolved
Hide resolved
...ode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java
Outdated
Show resolved
Hide resolved
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
Outdated
Show resolved
Hide resolved
|



This pull request introduces improvements to query execution management and resource cleanup in the IoTDB data node, with a focus on more accurate tracking of query execution time, robust handling of killed or missing queries, and improved resource cleanup logic. The most significant changes include the addition of per-RPC execution time tracking, better error responses for killed queries, and refactoring of resource cleanup mechanisms.
Query Execution Time Tracking and Management
updateCurrentRpcStartTime(long startTime)method to theIQueryExecutioninterface and its implementations (QueryExecution,ConfigExecution) to enable accurate measurement of per-RPC execution time and total query execution time, including in-progress RPCs. AdjustedrecordExecutionTimeandgetTotalExecutionTimeaccordingly. [1] [2] [3] [4]updateCurrentRpcStartTimemethod.Query Resource Cleanup and Error Handling
stopAndCleanup()method and ensuring that cleanup is triggered only when appropriate, such as when a client connection is inactive. Added a method to clear the coordinator context map if needed. [1] [2] [3] [4] [5]Coordinator.cleanupQueryExecutionto remove the query execution from the map at the start of the cleanup process, ensuring proper resource release.Client RPC Service Improvements
ClientRPCServiceImplfor thefetchResultsandfetchResultsV2methods: now returns a specific error status and message when a query is not found (e.g., killed, timed out), instead of a generic response. [1] [2] [3] [4]Code Quality and Testability
@TestOnlyannotations to certain constructors inMPPQueryContextto clarify their intended usage and refactored constructor chaining for better maintainability. [1] [2]Miscellaneous
These changes collectively improve the reliability, observability, and maintainability of query execution and resource management in the IoTDB data node.