Copilot commented on code in PR #60467:
URL: https://github.com/apache/doris/pull/60467#discussion_r2763001787
##########
fe/fe-common/src/main/java/org/apache/doris/common/Config.java:
##########
@@ -3584,6 +3584,22 @@ public static int metaServiceRpcRetryTimes() {
"Maximal concurrent num of get tablet stat job."})
public static int max_get_tablet_stat_task_threads_num = 4;
+ @ConfField(description = {"存算分离模式下检查 table 和 partition version 的间隔. 所有
frontend 都会检查",
+ "Cloud table and partition version checker interval. All frontends
will do checking"})
Review Comment:
The config description here says "All frontends will do checking", but
`CloudTableAndPartitionVersionChecker` is only started from
`CloudEnv.startMasterOnlyDaemonThreads`, so in practice only the master FE runs
the checker. Please either adjust the description to match the behavior or
start the checker (or an appropriate variant) on non-master FEs as well so the
configuration is not misleading.
```suggestion
@ConfField(description = {"存算分离模式下检查 table 和 partition version 的间隔,仅由
master frontend 执行检查",
"Cloud table and partition version checker interval. Only the
master frontend performs the checking"})
```
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudUpdateVersionTool.java:
##########
@@ -0,0 +1,209 @@
+// 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.
+
+package org.apache.doris.cloud.catalog;
+
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Partition;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.ClientPool;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.Pair;
+import org.apache.doris.system.Frontend;
+import org.apache.doris.system.SystemInfoService.HostInfo;
+import org.apache.doris.thrift.FrontendService;
+import org.apache.doris.thrift.TCloudVersionInfo;
+import org.apache.doris.thrift.TFrontendUpdateCloudVersionRequest;
+import org.apache.doris.thrift.TFrontendUpdateCloudVersionResult;
+import org.apache.doris.thrift.TNetworkAddress;
+import org.apache.doris.thrift.TStatusCode;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+public class CloudUpdateVersionTool {
+ private static final Logger LOG =
LogManager.getLogger(CloudUpdateVersionTool.class);
+
+ private static final ExecutorService UPDATE_VERSION_THREAD_POOL =
Executors.newFixedThreadPool(
+ Config.cloud_update_version_task_threads_num);
+
+ public CloudUpdateVersionTool() {
+ }
+
+ // master FE send update version rpc to other FEs
+ public void updateVersionAsync(long dbId, OlapTable table, long version) {
+ updateVersionAsync(dbId, Collections.singletonList(Pair.of(table,
version)), Collections.emptyMap());
+ }
+
+ public void updateVersionAsync(long dbId, List<Pair<OlapTable, Long>>
tableVersions,
+ Map<CloudPartition, Pair<Long, Long>> parititionVersionMap) {
+ UPDATE_VERSION_THREAD_POOL.submit(() -> {
+ try {
+ updateVersion(dbId, tableVersions, parititionVersionMap);
+ } catch (Exception e) {
+ LOG.warn("update table and partition version error", e);
+ }
+ });
+ }
+
+ private void updateVersion(long dbId, List<Pair<OlapTable, Long>>
tableVersions,
+ Map<CloudPartition, Pair<Long, Long>> parititionVersionMap) {
Review Comment:
`parititionVersionMap` is misspelled ("paritition" instead of "partition"),
which makes the parameter name harder to read and inconsistent with the rest of
the codebase. Consider renaming it (and its internal uses) to
`partitionVersionMap` for clarity.
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTableAndPartitionVersionChecker.java:
##########
@@ -0,0 +1,198 @@
+// 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.
+
+package org.apache.doris.cloud.catalog;
+
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Partition;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.util.MasterDaemon;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+public class CloudTableAndPartitionVersionChecker extends MasterDaemon {
+ private static final Logger LOG =
LogManager.getLogger(CloudTableAndPartitionVersionChecker.class);
+ private static final ExecutorService GET_VERSION_THREAD_POOL =
Executors.newFixedThreadPool(
+ Config.cloud_max_get_version_task_threads_num);
+
+ public CloudTableAndPartitionVersionChecker() {
+ super("cloud table and partition version checker",
+
Config.cloud_table_and_partition_version_checker_interval_second * 1000);
+ }
+
+ @Override
+ protected void runAfterCatalogReady() {
+ LOG.info("cloud table and partition version checker begin");
+ Map<OlapTable, Long> tableVersionMap = checkTableVersions();
+ if (!tableVersionMap.isEmpty()) {
+ updatePartitionVersion(tableVersionMap);
+ }
+ }
Review Comment:
This new multi-threaded checker orchestrates batched `get_version` RPCs and
partition refresh logic, but there are no unit tests covering its behavior,
while other cloud catalog components like `CloudPartition` have dedicated tests
(e.g.,
`fe/fe-core/src/test/java/org/apache/doris/cloud/catalog/CloudPartitionTest.java`).
Consider adding tests for `CloudTableAndPartitionVersionChecker` to validate
batching, TTL handling, and failure-path behavior to avoid regressions.
--
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]