ColinLeeo opened a new pull request, #18643: URL: https://github.com/apache/iotdb/pull/18643
## Summary `fetchResultsV2`, `fetchResults` and `closeOperation` take a `queryId` from the client and resolve it in the coordinator wide map of running queries. The request was only checked for login, not for whether that `queryId` was issued to the calling session, so a request could stream the result of a query, advance its cursor, or release it, on behalf of another session. This PR adds a session level validation of the client supplied `queryId`. When the query is not owned by the calling session, the request returns `NO_PERMISSION` and the running query is left untouched. A `queryId` that is no longer running keeps the previous behaviour, so a `closeOperation` sent after a result set was fully consumed still succeeds as usual. ## Changes - `IClientSession#containsQueryId(Long statementId, long queryId)` added. `ClientSession` and `InternalClientSession` implement it over the `statementId -> queryId` bookkeeping the sessions already keep; `MqttClientSession` and `RestClientSession` cannot submit queries and return `false`. A `null` statement id scans all of the session's query ids, which is what V1 `fetchResults` sends (the JDBC data set does not set a statement id on fetch). - `ClientRPCServiceImpl`: the check is applied in `fetchResultsV2`, `fetchResults` and `closeOperation`. The check runs after the existing lookup, so an unknown or killed `queryId` still returns `QUERY_WAS_KILLED` as before, and a rejected fetch neither records operation latency nor cleans the query up. - `closeOperation` only rejects when the query is still running; releasing an already released `queryId` remains a no-op. - Added the en/zh message and `QueryOwnershipTest`, covering the session bookkeeping, both fetch APIs, and the close path. ## Verification - `mvn test-compile -DskipTests` and `mvn test-compile -DskipTests -P with-zh-locale` - `mvn -pl iotdb-core/datanode -am -Dtest=QueryOwnershipTest -DfailIfNoTests=false test` -- 6 tests, all pass - `mvn spotless:apply -pl iotdb-core/datanode` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
