This is an automated email from the ASF dual-hosted git repository.
gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 596862b7a0e [fix](fe) cache version and get tablet stats actively for
RestoreJob (#62704)
596862b7a0e is described below
commit 596862b7a0e6714f81634c685fa5ba6c740b00b8
Author: meiyi <[email protected]>
AuthorDate: Tue Jun 2 19:21:56 2026 +0800
[fix](fe) cache version and get tablet stats actively for RestoreJob
(#62704)
---
.../java/org/apache/doris/backup/RestoreJob.java | 4 +-
.../apache/doris/cloud/backup/CloudRestoreJob.java | 45 +++++++++++++++++++++-
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
index 0aaa7140aaa..696bd055bb6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
@@ -2200,7 +2200,7 @@ public class RestoreJob extends AbstractJob implements
GsonPostProcessable {
}
}
- updateOlapTablesVersion(db);
+ updateOlapTablesVersion(db, isReplay);
if (!isReplay) {
restoredPartitions.clear();
@@ -2227,7 +2227,7 @@ public class RestoreJob extends AbstractJob implements
GsonPostProcessable {
return Status.OK;
}
- private void updateOlapTablesVersion(Database db) {
+ protected void updateOlapTablesVersion(Database db, boolean isReplay) {
if (Env.getCurrentEnv().invalidCacheForCloud()) {
return;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/cloud/backup/CloudRestoreJob.java
b/fe/fe-core/src/main/java/org/apache/doris/cloud/backup/CloudRestoreJob.java
index a9e6469a6d9..aafb0c66716 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/cloud/backup/CloudRestoreJob.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/cloud/backup/CloudRestoreJob.java
@@ -22,6 +22,7 @@ import org.apache.doris.backup.RestoreFileMapping.IdChain;
import org.apache.doris.backup.RestoreJob;
import org.apache.doris.backup.SnapshotInfo;
import org.apache.doris.backup.Status;
+import org.apache.doris.catalog.CloudTabletStatMgr;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.EnvFactory;
@@ -35,6 +36,7 @@ import org.apache.doris.catalog.Replica;
import org.apache.doris.catalog.ReplicaAllocation;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf;
+import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.TabletMeta;
import org.apache.doris.cloud.catalog.CloudEnv;
@@ -157,6 +159,36 @@ public class CloudRestoreJob extends RestoreJob {
}
}
+ @Override
+ protected void updateOlapTablesVersion(Database db, boolean isReplay) {
+ super.updateOlapTablesVersion(db, isReplay);
+ if (isReplay) {
+ return;
+ }
+ for (String tableName : jobInfo.backupOlapTableObjects.keySet()) {
+ Table tbl =
db.getTableNullable(jobInfo.getAliasByOriginNameIfSet(tableName));
+ if (tbl == null || tbl.getType() != TableType.OLAP) {
+ continue;
+ }
+ OlapTable olapTable = (OlapTable) tbl;
+
+ // sync version
+ List<Pair<OlapTable, Long>> tableVersionMap = Lists.newArrayList(
+ Pair.of(olapTable, olapTable.getCachedTableVersion()));
+ Map<CloudPartition, Pair<Long, Long>> partitionVersionMap = new
HashMap<>(olapTable.getPartitions().size());
+ for (Partition partition : olapTable.getPartitions()) {
+ CloudPartition cloudPartition = (CloudPartition) partition;
+ long version = cloudPartition.getCachedVisibleVersion();
+ partitionVersionMap.put(cloudPartition, Pair.of(version,
partition.getVisibleVersionTime()));
+ }
+ ((CloudEnv) env).getCloudFEVersionSynchronizer()
+ .pushVersionAsync(dbId, tableVersionMap,
partitionVersionMap);
+
+ // add active tablets to get stats
+
CloudTabletStatMgr.getInstance().addActiveTablets(olapTable.getAllTabletIds());
+ }
+ }
+
@Override
public void checkIfNeedCancel() {
super.checkIfNeedCancel();
@@ -463,6 +495,13 @@ public class CloudRestoreJob extends RestoreJob {
partitions.forEach(partition -> {
visibleVersions.add(partition.getCachedVisibleVersion());
partitionIds.add(partition.getId());
+ if (partition instanceof CloudPartition) {
+ ((CloudPartition)
partition).setCachedVisibleVersion(partition.getVisibleVersion(),
+ System.currentTimeMillis());
+ LOG.info("set cloud partition: {}, version: {},
versionTime: {}",
+ partition.getId(),
partition.getCachedVisibleVersion(),
+ partition.getVisibleVersionTime());
+ }
});
preparePartitions(olapTable, partitionIds, visibleVersions);
break;
@@ -504,8 +543,12 @@ public class CloudRestoreJob extends RestoreJob {
private void commitPartitions(OlapTable olapTable, List<Long>
partitionIds) throws DdlException {
try {
- ((CloudInternalCatalog)
Env.getCurrentInternalCatalog()).commitPartition(
+ long tableVersion = ((CloudInternalCatalog)
Env.getCurrentInternalCatalog()).commitPartition(
dbId, olapTable.getId(), partitionIds,
olapTable.getIndexIdList());
+ if (tableVersion > 0) {
+ olapTable.setCachedTableVersion(tableVersion);
+ LOG.info("set cloud table: {}, version: {}",
olapTable.getId(), tableVersion);
+ }
} catch (Exception e) {
String errMsg = String.format("cloud restore job failed to commit
partitions, table=%s, "
+ "partitions=%s, errMsg: %s", olapTable.getName(),
partitionIds, e.getMessage());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]