JackieTien97 opened a new pull request, #19260: URL: https://github.com/apache/iotdb/pull/19260
## 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.s1` and WRITE_DATA on `root.cq_read_auth.target.**` runs: ```sql SELECT * INTO root.cq_read_auth.target(::) FROM root.cq_read_auth.source ``` Before this change, the CQ also copied `source.s2`. Now only `s1` is 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 - Authorization uses `AuthorityChecker.checkAuthority(statement, session)`, which applies `QueryStatement.checkPermissionBeforeProcess` on this branch. The `AuthException` message is kept there, because `TreeAccessCheckVisitor` does not exist on `dev/1.3`. - Sessions carry no user ID on `dev/1.3`, so the master change that resolves the owner's user ID has no counterpart. Supplying the session still moves into the `try` block, so a failure there is cleaned up. - The warning constant, with the same name and en/zh text as master, goes into the existing `DataNodeQueryMessages` because `DataNodeMiscMessages` does not exist on this branch. - IT: `CREATE CQ` requires `USE_CQ` on `dev/1.3`, so the test grants `USE_CQ` instead of `SYSTEM`. Otherwise the IT is identical to master. - Unit test: `dev/1.3` has no `AccessControl` hook, so the test replaces `AuthorityChecker`'s memoized authority fetcher through `Whitebox` and 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. - `IoTDBCQExecIT` with SimpleIT (1C1D): 9 tests passed. Against the unpatched `dev/1.3` code, the 4 new cases fail: the wildcard CQ copies `s2`, and explicit-target windows return 200 instead of 701. - `IoTDBCQExecIT` with ClusterIT (1C3D): 9 tests passed. - `mvn test-compile -pl iotdb-core/datanode -am -P with-zh-locale -DskipTests` passed. - Spotless applied. This PR has: - [x] been self-reviewed. - [x] added unit and integration tests. - [x] been tested in 1 ConfigNode + 1 DataNode and 1 ConfigNode + 3 DataNode clusters. ##### Key changed classes - `DataNodeInternalRPCServiceImpl` - `QueryStatement` - `DataNodeQueryMessages` (en/zh) - `DataNodeInternalRPCServiceImplCQTest` - `IoTDBCQExecIT` 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
