Gabriel39 commented on code in PR #66247:
URL: https://github.com/apache/doris/pull/66247#discussion_r3697681969


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java:
##########
@@ -1047,8 +1050,35 @@ public void loadSnapshots(TableIf specificTable, 
Optional<TableSnapshot> tableSn
             MvccTableInfo mvccTableInfo = new MvccTableInfo(specificTable,
                     versionKeyOf(tableSnapshot, scanParams));
             if (!snapshots.containsKey(mvccTableInfo)) {
-                snapshots.put(mvccTableInfo,
-                        ((MvccTable) 
specificTable).loadSnapshot(tableSnapshot, scanParams));
+                MvccTable mvccTable = (MvccTable) specificTable;
+                MvccSnapshot snapshot;
+                if (mvccTable.requiresLatestSnapshotFence(tableSnapshot, 
scanParams)) {
+                    MvccTableInfo latestKey = new MvccTableInfo(specificTable);
+                    MvccSnapshot latestFence = 
latestSnapshotFences.computeIfAbsent(latestKey,
+                            key -> latestSnapshots.containsKey(key)
+                                    ? latestSnapshots.get(key) : 
mvccTable.loadLatestSnapshotFence());
+                    // Different planning projections remain separate, but 
their version selector
+                    // comes from one statement fence instead of repeated 
mutable latest reads.
+                    snapshot = mvccTable.loadSnapshot(tableSnapshot, 
scanParams, Optional.of(latestFence));
+                } else if (!tableSnapshot.isPresent() && 
!scanParams.isPresent()) {
+                    snapshot = latestSnapshots.computeIfAbsent(mvccTableInfo,
+                            key -> latestSnapshotFences.containsKey(key)

Review Comment:
   Addressed in 50b329982d. The prepared-execution boundary now clears all MVCC 
snapshot and resolved-option maps, with repeated EXECUTE coverage.



##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorMetadata.java:
##########
@@ -1301,30 +1324,41 @@ private ConnectorTableKey 
partitionViewCacheKey(PaimonTableHandle paimonHandle)
      * the partition columns and escapes path-special characters in the name 
via the Paimon SDK.
      */
     private List<ConnectorPartitionInfo> collectPartitions(PaimonTableHandle 
paimonHandle) {
+        if (PaimonScanParams.isPinnedEmptyScan(paimonHandle.getScanOptions())) 
{
+            // Do not reopen latest metadata after the statement fenced an 
empty table.
+            return Collections.emptyList();
+        }
         List<String> partitionKeys = paimonHandle.getPartitionKeys();
         // Legacy never lists partitions for unpartitioned tables: 
PaimonPartitionInfoLoader.load
         // returns EMPTY when partitionColumns is empty, so guard before 
touching the seam.
         if (partitionKeys == null || partitionKeys.isEmpty()) {
             return Collections.emptyList();
         }
 
-        // Partition enumeration is intentionally BASE-only: branch / 
time-travel reads carry EMPTY
-        // partition info (legacy PaimonPartitionInfo.EMPTY) and never reach 
this path, so for the
-        // (non-branch) handles that do, resolveTable returns the base table 
and the base-Identifier
-        // listing below is consistent. (A branch handle would otherwise mix 
branch schema metadata
-        // here with the base partition list — but that combination does not 
occur by design.)
-        Table table = resolveTable(paimonHandle);
+        Table resolvedTable = resolveTable(paimonHandle);
+        boolean optionsPin = 
PaimonScanParams.isOptionsPin(paimonHandle.getScanOptions());
+        Table table;
+        if (optionsPin) {
+            table = PaimonScanParams.applyOptions(resolvedTable, 
paimonHandle.getScanOptions());
+        } else {

Review Comment:
   Addressed in 50b329982d. Partition hydration now applies an ordinary 
positive snapshot pin before enumeration, with a focused partition-version test.



##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorMetadata.java:
##########
@@ -1474,8 +1511,13 @@ public Optional<ConnectorTableStatistics> 
getTableStatistics(
             Table table = resolveTable(pinned);
             Map<String, String> scanOptions = pinned.getScanOptions();
             if (scanOptions != null && !scanOptions.isEmpty()) {
-                table = table.copy(scanOptions);
+                table = PaimonScanParams.isOptionsPin(scanOptions)
+                        ? PaimonScanParams.applyOptions(table, scanOptions)

Review Comment:
   Addressed in 50b329982d. Snapshot statistics now short-circuit the 
pinned-empty fence before rowCount can reopen latest, with first-commit-race 
coverage.



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