[fix](restore) Reset next version for restored partitions (#38343)

Cherry-pick #38321
This commit is contained in:
walter
2024-07-25 16:07:54 +08:00
committed by GitHub
parent 32530113cf
commit 3d6689d32c
3 changed files with 36 additions and 2 deletions

View File

@ -82,6 +82,7 @@ import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.thrift.TStorageType;
import org.apache.doris.thrift.TTaskType;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
@ -1112,8 +1113,9 @@ public class RestoreJob extends AbstractJob {
// reset remote partition.
// reset all id in remote partition, but DO NOT modify any exist catalog objects.
private Partition resetPartitionForRestore(OlapTable localTbl, OlapTable remoteTbl, String partName,
ReplicaAllocation replicaAlloc) {
@VisibleForTesting
protected Partition resetPartitionForRestore(OlapTable localTbl, OlapTable remoteTbl, String partName,
ReplicaAllocation replicaAlloc) {
Preconditions.checkState(localTbl.getPartition(partName) == null);
Partition remotePart = remoteTbl.getPartition(partName);
Preconditions.checkNotNull(remotePart);
@ -1143,6 +1145,7 @@ public class RestoreJob extends AbstractJob {
// save version info for creating replicas
long visibleVersion = remotePart.getVisibleVersion();
remotePart.setNextVersion(visibleVersion + 1);
LOG.info("reset partition {} for restore, visible version: {}, old partition id: {}",
newPartId, visibleVersion, oldPartId);

View File

@ -348,6 +348,10 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
}
}
public void setPartitionInfo(PartitionInfo info) {
partitionInfo = info;
}
public boolean hasMaterializedIndex(String indexName) {
return indexNameToId.containsKey(indexName);
}