seawinde commented on code in PR #66255:
URL: https://github.com/apache/doris/pull/66255#discussion_r3709988143


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -3771,9 +3771,11 @@ private List<Partition> truncateTableInternal(OlapTable 
olapTable, List<Partitio
             
olapTable.dropPartitionForTruncate(olapTable.getDatabase().getId(), 
isforceDrop, pair.getValue());
         }
 
-        // Reset table-level visibleVersion to TABLE_INIT_VERSION so it stays 
consistent
-        // with the newly created partitions (which also start at 
PARTITION_INIT_VERSION).
-        olapTable.resetVisibleVersion();
+        // Truncate changes visible data without changing the table ID. Keep 
the table version
+        // monotonic so snapshot consumers cannot mistake new data for an old 
version.
+        if (Config.isNotCloudMode()) {

Review Comment:
   Fixed in . Cloud now takes the legacy/reset branch after the local partition 
swap, so  changes synchronously and fences stale local SimpleAgg cache entries. 
The authoritative Cloud table version remains Meta Service-managed; only 
non-Cloud applies the persisted positive version/time.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -3771,9 +3771,11 @@ private List<Partition> truncateTableInternal(OlapTable 
olapTable, List<Partitio
             
olapTable.dropPartitionForTruncate(olapTable.getDatabase().getId(), 
isforceDrop, pair.getValue());
         }
 
-        // Reset table-level visibleVersion to TABLE_INIT_VERSION so it stays 
consistent
-        // with the newly created partitions (which also start at 
PARTITION_INIT_VERSION).
-        olapTable.resetVisibleVersion();
+        // Truncate changes visible data without changing the table ID. Keep 
the table version
+        // monotonic so snapshot consumers cannot mistake new data for an old 
version.
+        if (Config.isNotCloudMode()) {
+            olapTable.updateVisibleVersionAndTime(olapTable.getNextVersion(), 
System.currentTimeMillis());

Review Comment:
   Addressed the journal compatibility pieces in : the non-Cloud version/time 
are selected while holding the table lock, persisted in , and replayed exactly. 
Missing fields deserialize to , so a new FE replaying an old record preserves 
the legacy reset behavior.\n\nI did not add a new electable-FE capability 
protocol because there is no existing journal capability gate that can reliably 
prove every electable FE understands these fields. An old binary will ignore 
the new fields, so mixed-version safety still relies on the supported 
upgrade/election ordering: an old FE must not be promoted after a new master 
starts emitting the new record. Adding distributed capability negotiation would 
be a broader upgrade-framework change rather than part of this table-version 
fix.



##########
regression-test/suites/mtmv_p0/test_truncate_table_mtmv.groovy:
##########
@@ -71,6 +86,18 @@ suite("test_truncate_table_mtmv","mtmv") {
         REFRESH MATERIALIZED VIEW ${mvName} AUTO
         """
     waitingMTMVTaskFinishedByMvName(mvName)
+
+    // Save a non-PCT table snapshot at version 3 while the MV does not 
contain k2=2.

Review Comment:
   Updated in :  is restored immediately after the first AUTO refresh wait, and 
the non-PCT ABA scenario now has a distinct  assertion. The corresponding  
entry still needs to be generated by the regression runner; repository policy 
forbids hand-writing it, and the owner-managed FE restart required by the 
regression gate has not been confirmed, so I am leaving this thread open until 
that artifact is generated.



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