Copilot commented on code in PR #62576:
URL: https://github.com/apache/doris/pull/62576#discussion_r3097820404


##########
regression-test/suites/cloud_p0/tablets/test_tablet_stat_syncer.groovy:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite("test_tablet_stat_syncer", "docker") {
+    if (!isCloudMode()) {
+        return
+    }
+
+    def options = new ClusterOptions()
+    options.setFeNum(2)
+    options.setBeNum(1)
+    options.cloudMode = true
+    options.enableDebugPoints()
+    options.connectToFollower = true
+
+    docker(options) {
+        def tbl = 'test_tablet_stat_syncer_tbl'
+        sql """ DROP TABLE IF EXISTS ${tbl} """
+
+        def configResult = sql_return_maparray """ ADMIN SHOW FRONTEND CONFIG 
LIKE '%cloud_get_tablet_stats_version%' """
+        assertTrue(configResult.size() > 0, "Expected to find 
cloud_get_tablet_stats_version config")
+        def tabletStatsVersion = configResult[0].Value.toInteger()
+        logger.info("cloud_get_tablet_stats_version = ${tabletStatsVersion}")
+        if (tabletStatsVersion != 2) {
+            logger.info("cloud_get_tablet_stats_version is not 2, skip test")
+            return
+        }
+
+        def intervalConfigResult = sql_return_maparray """ ADMIN SHOW FRONTEND 
CONFIG LIKE '%tablet_stat_update_interval_second%' """
+        assertTrue(intervalConfigResult.size() > 0, "Expected to find 
tablet_stat_update_interval_second config")
+        def statUpdateInterval = intervalConfigResult[0].Value.toInteger()
+        logger.info("tablet_stat_update_interval_second = 
${statUpdateInterval}")
+
+        sql """
+            CREATE TABLE IF NOT EXISTS ${tbl} (
+                id INT NOT NULL,
+                name VARCHAR(50) NOT NULL,
+                value INT NOT NULL
+            )
+            ENGINE = olap
+            DUPLICATE KEY(id)
+            DISTRIBUTED BY HASH(id) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+        """
+
+        def result = sql_return_maparray """ select * from ${tbl} """
+        assertEquals(0, result.size())
+
+        sql """ INSERT INTO ${tbl} VALUES (1, 'initial', 100) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 1 """
+        assertEquals(1, result.size())
+
+        def tablets = sql_return_maparray """ show tablets from ${tbl} """
+        assertTrue(tablets.size() > 0, "Expected at least one tablet")
+        def tabletIds = tablets.collect { it.TabletId }.join(",")
+        logger.info("Tablet IDs: ${tabletIds}")
+
+        def initialRowCount = tablets[0].RowCount
+        logger.info("Initial RowCount: ${initialRowCount}")
+
+        
GetDebugPoint().enableDebugPointForAllFEs("FE.CloudTabletStatMgr.addActiveTablets.ignore.tablets",
 [value: tabletIds])
+
+        sql """ INSERT INTO ${tbl} VALUES (2, 'test', 200) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 2 """
+        assertEquals(1, result.size(), "Data should be visible in query")
+
+        def tabletsAfterInsert = sql_return_maparray """ show tablets from 
${tbl} """
+        def rowCountAfterInsert = tabletsAfterInsert[0].RowCount
+        logger.info("RowCount after insert (before sync): 
${rowCountAfterInsert}")
+

Review Comment:
   The debug point only blocks `addActiveTablets`, but `CloudTabletStatMgr` can 
still refresh stats via the interval-ladder path. As written, the test doesn’t 
assert that RowCount stays stale while the debug point is enabled, so it can 
become flaky or pass without validating the intended behavior. Consider 
asserting RowCount remains unchanged for a short window (or set 
`tablet_stat_update_interval_second` high via FE configs) to make this 
deterministic.
   ```suggestion
           logger.info("RowCount after insert (before sync): 
${rowCountAfterInsert}")
           assertEquals(initialRowCount.toString(), 
rowCountAfterInsert.toString(),
                   "RowCount should remain stale immediately after insert while 
debug point is enabled")
   
           def staleCheckWindowMs = Math.max(2000, Math.min(5000, 
statUpdateInterval * 1000))
           def staleCheckIntervalMs = 500
           def staleCheckStart = System.currentTimeMillis()
           while (System.currentTimeMillis() - staleCheckStart < 
staleCheckWindowMs) {
               def tabletsDuringBlock = sql_return_maparray """ show tablets 
from ${tbl} """
               def rowCountDuringBlock = tabletsDuringBlock[0].RowCount
               logger.info("RowCount while debug point enabled: 
${rowCountDuringBlock}")
               assertEquals(initialRowCount.toString(), 
rowCountDuringBlock.toString(),
                       "RowCount should remain stale while debug point is 
enabled")
               Thread.sleep(staleCheckIntervalMs)
           }
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/catalog/CloudTabletStatMgr.java:
##########
@@ -575,6 +577,12 @@ public void addActiveTablets(List<Long> tabletIds) {
         if (Config.cloud_get_tablet_stats_version == 1 || tabletIds == null || 
tabletIds.isEmpty()) {
             return;
         }
+        List<String> ignoreTablets = 
Arrays.asList(DebugPointUtil.getDebugParamOrDefault(
+                "FE.CloudTabletStatMgr.addActiveTablets.ignore.tablets", 
"").split(","));
+        if (!ignoreTablets.isEmpty() && tabletIds.stream().anyMatch(id -> 
ignoreTablets.contains(String.valueOf(id)))) {
+            LOG.info("ignore adding active tablets: {}, debug param: {}", 
tabletIds, ignoreTablets);
+            return;

Review Comment:
   `addActiveTablets` runs on every commit in cloud mode, so splitting/parsing 
the debug param on every call adds avoidable allocations. Consider fetching the 
debug param string first and returning early when it’s empty, and parsing into 
a trimmed `Set<String>` (or `Set<Long>`) for faster `contains` checks. This 
matches the common pattern elsewhere (e.g., `Backend.isQueryAvailable` checks 
for empty before splitting).
   ```suggestion
           String ignoreTabletsParam = DebugPointUtil.getDebugParamOrDefault(
                   "FE.CloudTabletStatMgr.addActiveTablets.ignore.tablets", "");
           if (!ignoreTabletsParam.isEmpty()) {
               Set<String> ignoreTablets = 
Arrays.stream(ignoreTabletsParam.split(","))
                       .map(String::trim)
                       .filter(s -> !s.isEmpty())
                       .collect(Collectors.toSet());
               if (!ignoreTablets.isEmpty()
                       && tabletIds.stream().anyMatch(id -> 
ignoreTablets.contains(String.valueOf(id)))) {
                   LOG.info("ignore adding active tablets: {}, debug param: 
{}", tabletIds, ignoreTablets);
                   return;
               }
   ```



##########
regression-test/suites/cloud_p0/version/test_version_syncer.groovy:
##########
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite("test_version_syncer", "docker") {
+    if (!isCloudMode()) {
+        return
+    }
+
+    def options = new ClusterOptions()
+    options.setFeNum(2)
+    options.setBeNum(1)
+    options.cloudMode = true
+    options.enableDebugPoints()
+    options.connectToFollower = true
+
+    docker(options) {
+        def tbl = 'test_version_syncer_tbl'
+        sql """ DROP TABLE IF EXISTS ${tbl} """
+
+        def enableSyncerConfig = sql_return_maparray """ ADMIN SHOW FRONTEND 
CONFIG LIKE '%cloud_enable_version_syncer%' """
+        assertTrue(enableSyncerConfig.size() > 0, "Expected to find 
cloud_enable_version_syncer config")
+        def enableSyncer = enableSyncerConfig[0].Value.toBoolean()
+        logger.info("cloud_enable_version_syncer = ${enableSyncer}")
+        if (!enableSyncer) {
+            logger.info("FE.CloudGlobalTransactionMgr.updateVersion.disabled")
+            return
+        }
+        def configResult = sql_return_maparray """ ADMIN SHOW FRONTEND CONFIG 
LIKE '%cloud_version_syncer_interval_second%' """
+        assertTrue(configResult.size() > 0, "Expected to find 
cloud_version_syncer_interval_second config")
+        def syncerInterval = configResult[0].Value.toInteger()
+        logger.info("cloud_version_syncer_interval_second = ${syncerInterval}")
+
+        sql """
+                CREATE TABLE IF NOT EXISTS ${tbl} (
+                    id INT NOT NULL,
+                    name VARCHAR(50) NOT NULL,
+                    value INT NOT NULL
+                )
+                DUPLICATE KEY(id)
+                DISTRIBUTED BY HASH(id) BUCKETS 1
+                PROPERTIES (
+                    "replication_num" = "1"
+                );
+        """
+
+        def result = sql_return_maparray """ select * from ${tbl} """
+        assertEquals(0, result.size())
+
+        sql """ INSERT INTO ${tbl} VALUES (1, 'initial', 100) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 1 """
+        assertEquals(1, result.size())
+
+        
DebugPoint.enableDebugPointForAllFEs('FE.CloudGlobalTransactionMgr.updateVersion.disabled')
+
+        sql """ INSERT INTO ${tbl} VALUES (2, 'test', 200) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 2 """
+        assertEquals(0, result.size(), "Data should not be visible before 
version sync")
+
+        def maxWaitMs = (syncerInterval * 2 + 5) * 1000
+        def intervalMs = 1000
+        def startTime = System.currentTimeMillis()
+        def found = false
+        while (true) {
+            result = sql_return_maparray """ select * from ${tbl} where id = 2 
"""
+            if (result.size() == 1) {
+                assertEquals('test', result[0].name)
+                assertEquals(200, result[0].value)
+                found = true
+                break
+            }
+            if (System.currentTimeMillis() - startTime > maxWaitMs) {
+                throw new IllegalStateException("Timeout waiting for data to 
be visible. Waited ${maxWaitMs}ms")
+            }
+            Thread.sleep(intervalMs)

Review Comment:
   Debug point is enabled here but never disabled. Even though this is in a 
docker suite, leaving it enabled can affect later statements in the same test 
and makes failures harder to diagnose. Wrap the debug-point enable/disable in a 
try/finally (or explicitly disable it after the assertions) to ensure cleanup.
   ```suggestion
           try {
               sql """ INSERT INTO ${tbl} VALUES (2, 'test', 200) """
               result = sql_return_maparray """ select * from ${tbl} where id = 
2 """
               assertEquals(0, result.size(), "Data should not be visible 
before version sync")
   
               def maxWaitMs = (syncerInterval * 2 + 5) * 1000
               def intervalMs = 1000
               def startTime = System.currentTimeMillis()
               def found = false
               while (true) {
                   result = sql_return_maparray """ select * from ${tbl} where 
id = 2 """
                   if (result.size() == 1) {
                       assertEquals('test', result[0].name)
                       assertEquals(200, result[0].value)
                       found = true
                       break
                   }
                   if (System.currentTimeMillis() - startTime > maxWaitMs) {
                       throw new IllegalStateException("Timeout waiting for 
data to be visible. Waited ${maxWaitMs}ms")
                   }
                   Thread.sleep(intervalMs)
               }
           } finally {
               
DebugPoint.disableDebugPointForAllFEs('FE.CloudGlobalTransactionMgr.updateVersion.disabled')
   ```



##########
regression-test/suites/cloud_p0/version/test_version_syncer.groovy:
##########
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite("test_version_syncer", "docker") {
+    if (!isCloudMode()) {
+        return
+    }
+
+    def options = new ClusterOptions()
+    options.setFeNum(2)
+    options.setBeNum(1)
+    options.cloudMode = true
+    options.enableDebugPoints()
+    options.connectToFollower = true
+
+    docker(options) {
+        def tbl = 'test_version_syncer_tbl'
+        sql """ DROP TABLE IF EXISTS ${tbl} """
+
+        def enableSyncerConfig = sql_return_maparray """ ADMIN SHOW FRONTEND 
CONFIG LIKE '%cloud_enable_version_syncer%' """
+        assertTrue(enableSyncerConfig.size() > 0, "Expected to find 
cloud_enable_version_syncer config")
+        def enableSyncer = enableSyncerConfig[0].Value.toBoolean()
+        logger.info("cloud_enable_version_syncer = ${enableSyncer}")
+        if (!enableSyncer) {
+            logger.info("FE.CloudGlobalTransactionMgr.updateVersion.disabled")
+            return
+        }
+        def configResult = sql_return_maparray """ ADMIN SHOW FRONTEND CONFIG 
LIKE '%cloud_version_syncer_interval_second%' """
+        assertTrue(configResult.size() > 0, "Expected to find 
cloud_version_syncer_interval_second config")
+        def syncerInterval = configResult[0].Value.toInteger()
+        logger.info("cloud_version_syncer_interval_second = ${syncerInterval}")
+
+        sql """
+                CREATE TABLE IF NOT EXISTS ${tbl} (
+                    id INT NOT NULL,
+                    name VARCHAR(50) NOT NULL,
+                    value INT NOT NULL
+                )
+                DUPLICATE KEY(id)
+                DISTRIBUTED BY HASH(id) BUCKETS 1
+                PROPERTIES (
+                    "replication_num" = "1"
+                );
+        """
+
+        def result = sql_return_maparray """ select * from ${tbl} """
+        assertEquals(0, result.size())
+
+        sql """ INSERT INTO ${tbl} VALUES (1, 'initial', 100) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 1 """
+        assertEquals(1, result.size())
+
+        
DebugPoint.enableDebugPointForAllFEs('FE.CloudGlobalTransactionMgr.updateVersion.disabled')
+
+        sql """ INSERT INTO ${tbl} VALUES (2, 'test', 200) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 2 """
+        assertEquals(0, result.size(), "Data should not be visible before 
version sync")
+
+        def maxWaitMs = (syncerInterval * 2 + 5) * 1000
+        def intervalMs = 1000
+        def startTime = System.currentTimeMillis()
+        def found = false
+        while (true) {
+            result = sql_return_maparray """ select * from ${tbl} where id = 2 
"""
+            if (result.size() == 1) {
+                assertEquals('test', result[0].name)
+                assertEquals(200, result[0].value)
+                found = true
+                break
+            }
+            if (System.currentTimeMillis() - startTime > maxWaitMs) {
+                throw new IllegalStateException("Timeout waiting for data to 
be visible. Waited ${maxWaitMs}ms")
+            }
+            Thread.sleep(intervalMs)
+        }
+        assertTrue(found, "Data should eventually be visible after version 
syncer runs")
+
+        result = sql_return_maparray """ select * from ${tbl} order by id """
+        assertEquals(2, result.size())
+
+        // Test cloud_force_sync_version session variable
+        // Step 1: Insert data with version sync disabled, query should return 
no data
+        sql """ INSERT INTO ${tbl} VALUES (3, 'force_sync', 300) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 3 """
+        assertEquals(0, result.size(), "Data should not be visible before 
force sync")
+
+        // Step 2: Enable session variable cloud_force_sync_version = true and 
execute show partitions
+        sql """ set cloud_force_sync_version = true """
+        def showPartitionsResult = sql_return_maparray """ show partitions 
from ${tbl} """
+        logger.info("Show partitions result: ${showPartitionsResult}")
+
+        // Step 3: Query again, data should now be visible
+        result = sql_return_maparray """ select * from ${tbl} where id = 3 """
+        assertEquals(1, result.size(), "Data should be visible after force 
sync")

Review Comment:
   This test sets `cloud_force_sync_version = true` but never resets it. To 
avoid leaking session state into subsequent statements (or future additions to 
this suite), set it back to false in a finally block or immediately after the 
force-sync verification.
   ```suggestion
           try {
               sql """ set cloud_force_sync_version = true """
               def showPartitionsResult = sql_return_maparray """ show 
partitions from ${tbl} """
               logger.info("Show partitions result: ${showPartitionsResult}")
   
               // Step 3: Query again, data should now be visible
               result = sql_return_maparray """ select * from ${tbl} where id = 
3 """
               assertEquals(1, result.size(), "Data should be visible after 
force sync")
           } finally {
               sql """ set cloud_force_sync_version = false """
           }
   ```



##########
regression-test/suites/cloud_p0/tablets/test_tablet_stat_syncer.groovy:
##########
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+
+suite("test_tablet_stat_syncer", "docker") {
+    if (!isCloudMode()) {
+        return
+    }
+
+    def options = new ClusterOptions()
+    options.setFeNum(2)
+    options.setBeNum(1)
+    options.cloudMode = true
+    options.enableDebugPoints()
+    options.connectToFollower = true
+
+    docker(options) {
+        def tbl = 'test_tablet_stat_syncer_tbl'
+        sql """ DROP TABLE IF EXISTS ${tbl} """
+
+        def configResult = sql_return_maparray """ ADMIN SHOW FRONTEND CONFIG 
LIKE '%cloud_get_tablet_stats_version%' """
+        assertTrue(configResult.size() > 0, "Expected to find 
cloud_get_tablet_stats_version config")
+        def tabletStatsVersion = configResult[0].Value.toInteger()
+        logger.info("cloud_get_tablet_stats_version = ${tabletStatsVersion}")
+        if (tabletStatsVersion != 2) {
+            logger.info("cloud_get_tablet_stats_version is not 2, skip test")
+            return
+        }
+
+        def intervalConfigResult = sql_return_maparray """ ADMIN SHOW FRONTEND 
CONFIG LIKE '%tablet_stat_update_interval_second%' """
+        assertTrue(intervalConfigResult.size() > 0, "Expected to find 
tablet_stat_update_interval_second config")
+        def statUpdateInterval = intervalConfigResult[0].Value.toInteger()
+        logger.info("tablet_stat_update_interval_second = 
${statUpdateInterval}")
+
+        sql """
+            CREATE TABLE IF NOT EXISTS ${tbl} (
+                id INT NOT NULL,
+                name VARCHAR(50) NOT NULL,
+                value INT NOT NULL
+            )
+            ENGINE = olap
+            DUPLICATE KEY(id)
+            DISTRIBUTED BY HASH(id) BUCKETS 1
+            PROPERTIES (
+                "replication_num" = "1"
+            );
+        """
+
+        def result = sql_return_maparray """ select * from ${tbl} """
+        assertEquals(0, result.size())
+
+        sql """ INSERT INTO ${tbl} VALUES (1, 'initial', 100) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 1 """
+        assertEquals(1, result.size())
+
+        def tablets = sql_return_maparray """ show tablets from ${tbl} """
+        assertTrue(tablets.size() > 0, "Expected at least one tablet")
+        def tabletIds = tablets.collect { it.TabletId }.join(",")
+        logger.info("Tablet IDs: ${tabletIds}")
+
+        def initialRowCount = tablets[0].RowCount
+        logger.info("Initial RowCount: ${initialRowCount}")
+
+        
GetDebugPoint().enableDebugPointForAllFEs("FE.CloudTabletStatMgr.addActiveTablets.ignore.tablets",
 [value: tabletIds])
+
+        sql """ INSERT INTO ${tbl} VALUES (2, 'test', 200) """
+        result = sql_return_maparray """ select * from ${tbl} where id = 2 """
+        assertEquals(1, result.size(), "Data should be visible in query")
+
+        def tabletsAfterInsert = sql_return_maparray """ show tablets from 
${tbl} """
+        def rowCountAfterInsert = tabletsAfterInsert[0].RowCount
+        logger.info("RowCount after insert (before sync): 
${rowCountAfterInsert}")
+
+        
GetDebugPoint().disableDebugPointForAllFEs("FE.CloudTabletStatMgr.addActiveTablets.ignore.tablets")
+
+        def maxWaitMs = (statUpdateInterval * 3 + 5) * 1000
+        def intervalMs = 1000
+        def startTime = System.currentTimeMillis()
+        def updated = false
+        while (true) {
+            def tabletsNow = sql_return_maparray """ show tablets from ${tbl} 
"""
+            def rowCountNow = tabletsNow[0].RowCount.toInteger()
+            logger.info("RowCount get: ${rowCountNow}")
+            if (rowCountNow == 2) {
+                logger.info("RowCount updated: ${rowCountNow}")
+                updated = true
+                break
+            }
+            if (System.currentTimeMillis() - startTime > maxWaitMs) {
+                throw new IllegalStateException("Timeout waiting for tablet 
stat update. Waited ${maxWaitMs}ms, RowCount still ${rowCountNow}")
+            }
+            Thread.sleep(intervalMs)
+        }
+        assertTrue(updated, "Tablet stat should eventually update after debug 
point disabled")
+        tabletsAfterInsert = sql_return_maparray """ show tablets from ${tbl} 
"""
+        rowCountAfterInsert = tabletsAfterInsert[0].RowCount.toInteger()
+        logger.info("RowCount after stat sync: ${rowCountAfterInsert}")
+        assertEquals(2, rowCountAfterInsert, "RowCount should reflect the new 
row after stat sync")
+
+        sql """ INSERT INTO ${tbl} VALUES (3, 'force_sync', 300) """
+        def tabletsBeforeSync = sql_return_maparray """ show tablets from 
${tbl} """
+        def localDataSizeBeforeSync = tabletsBeforeSync[0].LocalDataSize
+        def rowCountBeforeSync = tabletsBeforeSync[0].RowCount
+        logger.info("LocalDataSize before force sync: 
${localDataSizeBeforeSync}, RowCount: ${rowCountBeforeSync}")
+
+        sql """ set cloud_force_sync_tablet_stats = true """
+        def tabletsAfterForceSync = sql_return_maparray """ show tablets from 
${tbl} """
+        def localDataSizeAfterForceSync = 
tabletsAfterForceSync[0].LocalDataSize
+        def rowCountAfterForceSync = tabletsAfterForceSync[0].RowCount
+        logger.info("LocalDataSize after force sync: 
${localDataSizeAfterForceSync}, RowCount: ${rowCountAfterForceSync}")
+        sql """ set cloud_force_sync_tablet_stats = false """
+
+        startTime = System.currentTimeMillis()
+        updated = false
+        while (true) {
+            def tabletsNow = sql_return_maparray """ show tablets from ${tbl} 
"""
+            def rowCountNow = tabletsNow[0].RowCount.toInteger()
+            logger.info("RowCount get 3: ${rowCountNow}")
+            if (rowCountNow == 3) {
+                logger.info("RowCount updated 3: ${rowCountNow}")
+                updated = true
+                break
+            }
+            if (System.currentTimeMillis() - startTime > maxWaitMs) {
+                throw new IllegalStateException("Timeout waiting for tablet 
stat update. Waited ${maxWaitMs}ms, RowCount still ${rowCountNow}")
+            }
+            Thread.sleep(intervalMs)
+        }
+        assertTrue(updated, "Tablet stat should eventually update after debug 
point disabled")
+        tabletsAfterInsert = sql_return_maparray """ show tablets from ${tbl} 
"""
+        rowCountAfterInsert = tabletsAfterInsert[0].RowCount.toInteger()
+        logger.info("RowCount after stat sync: ${rowCountAfterInsert}")
+        assertEquals(3, rowCountAfterInsert, "RowCount should reflect the new 
row after stat sync")

Review Comment:
   The `cloud_force_sync_tablet_stats` section doesn’t currently prove that the 
session variable changes behavior: after inserting id=3, tablet stats may 
update naturally on the next scheduled refresh even if force sync is 
ineffective. To make this a real regression case, block/disable background 
refresh (e.g., reuse the ignore debug point, or increase update intervals), 
then assert that stats only update after enabling 
`cloud_force_sync_tablet_stats` and issuing the triggering statement (e.g. 
`show tablets`).
   ```suggestion
           
GetDebugPoint().enableDebugPointForAllBEs("CloudTabletStatMgr::sync_tablet_stat.ignore")
           try {
               sql """ INSERT INTO ${tbl} VALUES (3, 'force_sync', 300) """
               def tabletsBeforeSync = sql_return_maparray """ show tablets 
from ${tbl} """
               def localDataSizeBeforeSync = tabletsBeforeSync[0].LocalDataSize
               def rowCountBeforeSync = 
tabletsBeforeSync[0].RowCount.toInteger()
               logger.info("LocalDataSize before force sync: 
${localDataSizeBeforeSync}, RowCount: ${rowCountBeforeSync}")
               assertEquals(2, rowCountBeforeSync,
                       "RowCount should remain stale while background tablet 
stat sync is blocked")
   
               sql """ set cloud_force_sync_tablet_stats = true """
               def tabletsAfterForceSync = sql_return_maparray """ show tablets 
from ${tbl} """
               def localDataSizeAfterForceSync = 
tabletsAfterForceSync[0].LocalDataSize
               def rowCountAfterForceSync = 
tabletsAfterForceSync[0].RowCount.toInteger()
               logger.info("LocalDataSize after force sync: 
${localDataSizeAfterForceSync}, RowCount: ${rowCountAfterForceSync}")
               assertEquals(3, rowCountAfterForceSync,
                       "RowCount should update immediately only after force 
sync is enabled and show tablets is issued")
           } finally {
               sql """ set cloud_force_sync_tablet_stats = false """
               
GetDebugPoint().disableDebugPointForAllBEs("CloudTabletStatMgr::sync_tablet_stat.ignore")
           }
   ```



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