github-actions[bot] commented on code in PR #66530:
URL: https://github.com/apache/doris/pull/66530#discussion_r4055997127


##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonScanPlanProvider.java:
##########
@@ -538,8 +540,59 @@ public void releaseReadTransaction(String queryId) {
      */
     @Override
     public List<ConnectorScanRange> planScan(ConnectorSession session, 
ConnectorScanRequest request) {
-        return planScanInternal(session, request.getTableHandle(), 
request.getColumns(),
-                request.getFilter(), request.getLimit(), 
request.isCountPushdown());
+        PaimonTableHandle paimonHandle = (PaimonTableHandle) 
request.getTableHandle();
+        if (session == null || !session.isExternalScanTaskReuseEnabled()) {
+            return planScanInternal(session, request.getTableHandle(), 
request.getColumns(),
+                    request.getFilter(), request.getLimit(), 
request.isCountPushdown());
+        }
+        if (paimonHandle.isSystemTable()) {
+            // System tables resolve their snapshot on the BE and carry 
deferred side effects
+            // (authorized file enumeration); never reuse their planned ranges.
+            return planScanInternal(session, request.getTableHandle(), 
request.getColumns(),
+                    request.getFilter(), request.getLimit(), 
request.isCountPushdown());
+        }
+        // Resolve the table ONCE at the statement scope so both the 
scan-planning path (here) and
+        // the properties path (getScanNodeProperties) observe the SAME table 
generation. Without
+        // this, a no-cache catalog or a schema change between two aliases can 
give alias A's ranges
+        // to alias B's generation-B serialized table.
+        Table table = resolveScanTableConsistent(session, paimonHandle);
+        long generation = resolvePaimonGeneration(table);

Review Comment:
   [P1] Authenticate the generation snapshot read
   
   With reuse enabled (the default), this call runs after `resolveScanTable` 
has left `executeAuthenticated`. The production `latestSnapshotId` 
implementation calls `Table.latestSnapshot()`, which reaches a snapshot loader 
or the table's FileIO; as the nearby `planSplits` path documents, a 
Kerberos-backed plugin otherwise runs with SIMPLE credentials. The updated 
test's `authCount == 2` also confirms this new probe is outside the 
authenticated table-load and split-enumeration calls. Please execute the 
generation lookup under `ConnectorContext.executeAuthenticated` (preserving the 
null-context fallback) and cover a context that rejects `latestSnapshotId` 
outside authentication.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to