Conversation
fetchResultsV2, fetchResults and closeOperation resolve the queryId sent by the client in the coordinator wide map of running queries, without checking which session submitted that query. Add a per session validation of the queryId and return NO_PERMISSION when it was not issued to the calling session, so that the running query is neither read nor released by another session. - add IClientSession.containsQueryId, implemented on ClientSession and InternalClientSession over the statementId -> queryId bookkeeping that already exists, and on MqttClientSession/RestClientSession which cannot submit queries - check the queryId in fetchResultsV2, fetchResults and closeOperation; a queryId that is no longer running keeps the previous behaviour - a rejected fetch does not record latency or clean up the query - add the en/zh message and a unit test covering the two fetch APIs, the close path and the session level bookkeeping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fetchResultsV2,fetchResultsandcloseOperationtake aqueryIdfrom the client and resolve it in the coordinator wide map of running queries. The request was only checked for login, not for whether thatqueryIdwas 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 returnsNO_PERMISSIONand the running query is left untouched. AqueryIdthat is no longer running keeps the previous behaviour, so acloseOperationsent after a result set was fully consumed still succeeds as usual.Changes
IClientSession#containsQueryId(Long statementId, long queryId)added.ClientSessionandInternalClientSessionimplement it over thestatementId -> queryIdbookkeeping the sessions already keep;MqttClientSessionandRestClientSessioncannot submit queries and returnfalse. Anullstatement id scans all of the session's query ids, which is what V1fetchResultssends (the JDBC data set does not set a statement id on fetch).ClientRPCServiceImpl: the check is applied infetchResultsV2,fetchResultsandcloseOperation. The check runs after the existing lookup, so an unknown or killedqueryIdstill returnsQUERY_WAS_KILLEDas before, and a rejected fetch neither records operation latency nor cleans the query up.closeOperationonly rejects when the query is still running; releasing an already releasedqueryIdremains a no-op.QueryOwnershipTest, covering the session bookkeeping, both fetch APIs, and the close path.Verification
mvn test-compile -DskipTestsandmvn test-compile -DskipTests -P with-zh-localemvn -pl iotdb-core/datanode -am -Dtest=QueryOwnershipTest -DfailIfNoTests=false test-- 6 tests, all passmvn spotless:apply -pl iotdb-core/datanode