Skip to content

Commit

Permalink
fix backup and restore failed between force_replication_allocation se…
Browse files Browse the repository at this point in the history
…tted and not setted clusters (#34608)
  • Loading branch information
cambyzju authored and Doris-Extras committed May 18, 2024
1 parent 6c515e0 commit f780194
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.doris.backup.Repository;
import org.apache.doris.catalog.ReplicaAllocation;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
Expand Down Expand Up @@ -168,6 +169,10 @@ public void analyzeProperties() throws AnalysisException {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
"Invalid reserve_replica value: " + copiedProperties.get(PROP_RESERVE_REPLICA));
}
// force set reserveReplica to false, do not keep the origin allocation
if (reserveReplica && !Config.force_olap_table_replication_allocation.isEmpty()) {
reserveReplica = false;
}
copiedProperties.remove(PROP_RESERVE_REPLICA);
}
// reserve dynamic partition enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.catalog.Tablet;
import org.apache.doris.catalog.View;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.Version;
import org.apache.doris.common.io.Text;
Expand Down Expand Up @@ -99,6 +100,8 @@ public class BackupJobInfo implements Writable {
public int minorVersion;
@SerializedName("patch_version")
public int patchVersion;
@SerializedName("is_force_replication_allocation")
public boolean isForceReplicationAllocation;

@SerializedName("tablet_be_map")
public Map<Long, Long> tabletBeMap = Maps.newHashMap();
Expand Down Expand Up @@ -607,6 +610,7 @@ public static BackupJobInfo fromCatalog(long backupTime, String label, String db
jobInfo.majorVersion = Version.DORIS_BUILD_VERSION_MAJOR;
jobInfo.minorVersion = Version.DORIS_BUILD_VERSION_MINOR;
jobInfo.patchVersion = Version.DORIS_BUILD_VERSION_PATCH;
jobInfo.isForceReplicationAllocation = !Config.force_olap_table_replication_allocation.isEmpty();

Collection<Table> tbls = backupMeta.getTables().values();
// tbls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public RestoreJob(String label, String backupTs, long dbId, String dbName, Backu
this.state = RestoreJobState.PENDING;
this.metaVersion = metaVersion;
this.reserveReplica = reserveReplica;
// if backup snapshot is come from a cluster with force replication allocation, ignore the origin allocation
if (jobInfo.isForceReplicationAllocation) {
this.reserveReplica = false;
}
this.reserveDynamicPartitionEnable = reserveDynamicPartitionEnable;
this.isBeingSynced = isBeingSynced;
properties.put(PROP_RESERVE_REPLICA, String.valueOf(reserveReplica));
Expand Down

0 comments on commit f780194

Please sign in to comment.