JackieTien97 commented on code in PR #19234:
URL: https://github.com/apache/iotdb/pull/19234#discussion_r4558423988


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java:
##########
@@ -1887,6 +1888,17 @@ public TSStatus executeCQ(TExecuteCQ req) {
       }
       executedSQL = String.join(" ", 
s.constructFormattedSQL().split("\n")).replaceAll(" +", " ");
 
+      // Refresh the owner's READ_DATA scope for each CQ execution.
+      TSStatus status =
+          AuthorityChecker.checkAuthority(

Review Comment:
   Addressed in 17d1fefc56 by keeping the existing semantics and making them 
explicit. Explicit target columns keep ordinary SELECT INTO's positional 
mapping, so partial READ_DATA still fails the window with 701 without writing 
any column, and the scheduler retries the same window until access is restored 
(catching up window by window under BLOCKED). The PR description now documents 
this, and `testCQExecutionWithExplicitTargetReadDataPermission` / 
`testCQExecutionWithExplicitTargetReadDataPermissionAlignByDevice` pin the 701 
failure, the retry of the same window after re-granting, and the resulting rows.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java:
##########
@@ -1887,6 +1888,17 @@ public TSStatus executeCQ(TExecuteCQ req) {
       }
       executedSQL = String.join(" ", 
s.constructFormattedSQL().split("\n")).replaceAll(" +", " ");
 
+      // Refresh the owner's READ_DATA scope for each CQ execution.
+      TSStatus status =
+          AuthorityChecker.checkAuthority(
+              s,
+              new TreeAccessCheckContext(
+                      session.getUserId(), session.getUsername(), 
session.getClientAddress())

Review Comment:
   Fixed in 17d1fefc56: the internal session is now supplied with 
`AuthorityChecker.getUserId(req.getUsername()).orElse(-1L)`, which resolves the 
TODO. `DataNodeInternalRPCServiceImplCQTest` verifies that the real user ID 
reaches both the access-check context and the query execution session.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java:
##########
@@ -1887,6 +1888,17 @@ public TSStatus executeCQ(TExecuteCQ req) {
       }
       executedSQL = String.join(" ", 
s.constructFormattedSQL().split("\n")).replaceAll(" +", " ");
 
+      // Refresh the owner's READ_DATA scope for each CQ execution.
+      TSStatus status =
+          AuthorityChecker.checkAuthority(
+              s,
+              new TreeAccessCheckContext(
+                      session.getUserId(), session.getUsername(), 
session.getClientAddress())
+                  .setSqlString(executedSQL));
+      if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+        return status;

Review Comment:
   Fixed in 17d1fefc56: `TreeAccessCheckVisitor.visitQuery` now keeps 
`e.getMessage()` on `AuthException`, and `executeCQ` logs a WARN with the CQ 
ID, owner, and status when authorization fails (new en/zh constant 
`LOG_FAILED_TO_AUTHORIZE_CQ_ARG_FOR_USER_ARG_ARG_B436A81F`). The deleted-owner 
step in `IoTDBCQExecIT` asserts a 301 status whose message contains the 
username.



-- 
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]

Reply via email to