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 @@ -1527,6 +1527,12 @@ public class Config extends ConfigBase {
@ConfField(mutable = true, masterOnly = true)
public static int max_backup_restore_job_num_per_db = 10;

/**
* whether to ignore temp partitions when backup, and not report exception.
*/
@ConfField(mutable = true, masterOnly = true)
public static boolean ignore_backup_tmp_partitions = false;

/**
* Control the default max num of the instance for a user.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,14 @@ private void backup(Repository repository, Database db, BackupStmt stmt) throws
OlapTable olapTbl = (OlapTable) tbl;
tbl.readLock();
try {
if (olapTbl.existTempPartitions()) {
if (!Config.ignore_backup_tmp_partitions && olapTbl.existTempPartitions()) {
ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
"Do not support backup table with temp partitions");
}

PartitionNames partitionNames = tblRef.getPartitionNames();
if (partitionNames != null) {
if (partitionNames.isTemp()) {
if (!Config.ignore_backup_tmp_partitions && partitionNames.isTemp()) {
ErrorReport.reportDdlException(ErrorCode.ERR_COMMON_ERROR,
"Do not support backup temp partitions");
}
Expand Down
15 changes: 10 additions & 5 deletions fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,15 @@ private void prepareSnapshotTaskForOlapTableWithoutLock(OlapTable olapTable,
// check backup table again
if (backupTableRef.getPartitionNames() != null) {
for (String partName : backupTableRef.getPartitionNames().getPartitionNames()) {
Partition partition = olapTable.getPartition(partName);
Partition partition = olapTable.getPartition(partName, false); // exclude tmp partitions
if (partition == null) {
status = new Status(ErrCode.NOT_FOUND, "partition " + partName
+ " does not exist in table" + backupTableRef.getName().getTbl());
if (olapTable.getPartition(partName, true) != null) {
status = new Status(ErrCode.NOT_FOUND, "backup tmp partition " + partName
+ " in table " + backupTableRef.getName().getTbl() + " is not supported");
} else {
status = new Status(ErrCode.NOT_FOUND, "partition " + partName
+ " does not exist in table " + backupTableRef.getName().getTbl());
}
return;
}
}
Expand All @@ -460,10 +465,10 @@ private void prepareSnapshotTaskForOlapTableWithoutLock(OlapTable olapTable,
// create snapshot tasks
List<Partition> partitions = Lists.newArrayList();
if (backupTableRef.getPartitionNames() == null) {
partitions.addAll(olapTable.getPartitions());
partitions.addAll(olapTable.getPartitions()); // no temp partitions in OlapTable.getPartitions()
} else {
for (String partName : backupTableRef.getPartitionNames().getPartitionNames()) {
Partition partition = olapTable.getPartition(partName);
Partition partition = olapTable.getPartition(partName, false); // exclude tmp partitions
partitions.add(partition);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,14 @@ public OlapTable selectiveCopy(Collection<String> reservedPartitions, IndexExtSt
}
}

if (isForBackup) {
// drop all tmp partitions in copied table
for (Partition partition : copied.tempPartitions.getAllPartitions()) {
copied.partitionInfo.dropPartition(partition.getId());
}
copied.tempPartitions = new TempPartitions();
}

if (reservedPartitions == null || reservedPartitions.isEmpty()) {
// reserve all
return copied;
Expand Down
Loading