Repository navigation
[To dev/1.3] [CQ] Check READ_DATA permissions during continuous query execution (#19234) - #19260
Merged
Merged
Conversation
…19234) Backport of #19234 to dev/1.3. Tree-model CQ execution skipped the query authorization step, so a CQ could copy series on which its owner had no READ_DATA privilege. Check the owner's current READ_DATA scope before each execution, keep the authorization failure's message, and log a warning with the CQ ID and owner when authorization fails. Adaptations for dev/1.3: - Authorize with AuthorityChecker.checkAuthority(statement, session), which applies QueryStatement.checkPermissionBeforeProcess on this branch, and keep the AuthException message there instead of in TreeAccessCheckVisitor. - Sessions carry no user ID on this branch, so resolving the owner's user ID has no counterpart. Supplying the session still moves into the try block, so a failure there is cleaned up. - Add the warning constant to the existing DataNodeQueryMessages (en/zh) because DataNodeMiscMessages does not exist on this branch. - IT: grant USE_CQ instead of SYSTEM for CREATE CQ. - Unit test: replace AuthorityChecker's memoized authority fetcher, since there is no AccessControl hook, and drop the user-ID assertions. (cherry picked from commit cca1dbb)
|
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.



Description
Backport of #19234 to
dev/1.3.Tree-model CQ execution skips the query authorization step, so a CQ copies series on which its owner has no READ_DATA privilege. For example, an owner with READ_DATA only on
root.cq_read_auth.source.s1and WRITE_DATA onroot.cq_read_auth.target.**runs:Before this change, the CQ also copied
source.s2. Now onlys1is copied. As on master, CQs with explicit target columns keep SELECT INTO's positional mapping: under partial READ_DATA, the window fails with 701 without writing any column, and the scheduler retries it until access is restored. If the owner is deleted, authorization fails with a message that includes the username, and the DataNode logs a warning with the CQ ID and owner.Adaptations for dev/1.3
AuthorityChecker.checkAuthority(statement, session), which appliesQueryStatement.checkPermissionBeforeProcesson this branch. TheAuthExceptionmessage is kept there, becauseTreeAccessCheckVisitordoes not exist ondev/1.3.dev/1.3, so the master change that resolves the owner's user ID has no counterpart. Supplying the session still moves into thetryblock, so a failure there is cleaned up.DataNodeQueryMessagesbecauseDataNodeMiscMessagesdoes not exist on this branch.CREATE CQrequiresUSE_CQondev/1.3, so the test grantsUSE_CQinstead ofSYSTEM. Otherwise the IT is identical to master.dev/1.3has noAccessControlhook, so the test replacesAuthorityChecker's memoized authority fetcher throughWhiteboxand drops the user-ID assertions. The scenarios are unchanged: a failed authorization returns before schema analysis, the owner reaches the READ_DATA lookup and the query session, and the session and query executions are cleaned up.Validation
DataNodeInternalRPCServiceImplCQTest: 2 tests passed. With the authorization block removed, both fail.IoTDBCQExecITwith SimpleIT (1C1D): 9 tests passed. Against the unpatcheddev/1.3code, the 4 new cases fail: the wildcard CQ copiess2, and explicit-target windows return 200 instead of 701.IoTDBCQExecITwith ClusterIT (1C3D): 9 tests passed.mvn test-compile -pl iotdb-core/datanode -am -P with-zh-locale -DskipTestspassed.This PR has:
Key changed classes
DataNodeInternalRPCServiceImplQueryStatementDataNodeQueryMessages(en/zh)DataNodeInternalRPCServiceImplCQTestIoTDBCQExecIT🤖 Generated with Claude Code