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


##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonScanPlanProvider.java:
##########
@@ -538,8 +540,72 @@ 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:
   [P2] Avoid re-reading live latest for already-fixed scan identities. 
Normal/latest, snapshot/timestamp, branch, statement-fenced options, and 
pinned-empty reads reach this method with their scan identity fixed on the 
handle, but this probe runs before `scanReuse.computeIfAbsent`. N equal aliases 
therefore still perform N authenticated snapshot-pointer reads (the changed 
test explicitly expects two); if latest advances from S1 to S2 between aliases, 
the generation field also forces another full retained plan even though both 
requests still scan pinned S1. Derive or memoize the generation for fixed 
handles, and keep live fencing or bypass reuse only for genuinely 
latest-dependent selectors such as open-ended `@incr`. Please cover both cases, 
plus a pinned-empty path that does not probe latest.



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