Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ protected Status allTabletCommitted(boolean isReplay) {
}
}

updateOlapTablesVersion(db);
updateOlapTablesVersion(db, isReplay);

if (!isReplay) {
restoredPartitions.clear();
Expand All @@ -2199,7 +2199,7 @@ protected Status allTabletCommitted(boolean isReplay) {
return Status.OK;
}

private void updateOlapTablesVersion(Database db) {
protected void updateOlapTablesVersion(Database db, boolean isReplay) {
if (Env.getCurrentEnv().invalidCacheForCloud()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand All @@ -35,6 +36,7 @@
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;
Expand Down Expand Up @@ -157,6 +159,36 @@ public synchronized void run() {
}
}

@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()));
}
Comment on lines +175 to +183
((CloudEnv) env).getCloudFEVersionSynchronizer()
.pushVersionAsync(dbId, tableVersionMap, partitionVersionMap);

// add active tablets to get stats
CloudTabletStatMgr.getInstance().addActiveTablets(olapTable.getAllTabletIds());
}
}

@Override
public void checkIfNeedCancel() {
super.checkIfNeedCancel();
Expand Down Expand Up @@ -462,6 +494,13 @@ private void handleOlapTableMeta(MetaSeriviceOperation operation, OlapTable olap
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());
}
Comment on lines +498 to +503
});
preparePartitions(olapTable, partitionIds, visibleVersions);
break;
Expand Down Expand Up @@ -503,8 +542,12 @@ private void preparePartitions(OlapTable olapTable, List<Long> partitionIds, Lis

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());
Expand Down
Loading