924060929 commented on code in PR #66530:
URL: https://github.com/apache/doris/pull/66530#discussion_r4056738414


##########
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:
   Fixed in 616b309de36. Fixed snapshot identities now use their pinned 
snapshot id as the reuse generation, and pinned-empty identities skip the live 
latest lookup entirely. Latest-dependent selectors such as open-ended 
incremental scans still read and fence on the live generation. Added coverage 
for all three paths; PaimonScanPlanProviderTest passes 103/103 and ./build.sh 
--fe passes.



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