Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix accidental table deletion during restore job #48820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ private void checkAndPrepareMeta() {

// Check and prepare meta objects.
Map<Long, AgentBatchTask> batchTaskPerTable = new HashMap<>();

// The tables that are restored but not committed, because the table name may be changed.
List<Table> stagingRestoreTables = Lists.newArrayList();
db.readLock();
try {
for (Map.Entry<String, BackupOlapTableInfo> olapTableEntry : jobInfo.backupOlapTableObjects.entrySet()) {
Expand Down Expand Up @@ -882,7 +885,7 @@ private void checkAndPrepareMeta() {
if (LOG.isDebugEnabled()) {
LOG.debug("put remote table {} to restoredTbls", remoteOlapTbl.getName());
}
restoredTbls.add(remoteOlapTbl);
stagingRestoreTables.add(remoteOlapTbl);
}
} // end of all restore olap tables

Expand Down Expand Up @@ -911,7 +914,7 @@ private void checkAndPrepareMeta() {
String srcDbName = jobInfo.dbName;
remoteView.resetViewDefForRestore(srcDbName, db.getName());
remoteView.resetIdsForRestore(env);
restoredTbls.add(remoteView);
stagingRestoreTables.add(remoteView);
}
}

Expand All @@ -932,7 +935,7 @@ private void checkAndPrepareMeta() {
}
} else {
remoteOdbcTable.resetIdsForRestore(env);
restoredTbls.add(remoteOdbcTable);
stagingRestoreTables.add(remoteOdbcTable);
}
}

Expand Down Expand Up @@ -965,7 +968,7 @@ private void checkAndPrepareMeta() {
}

// generate create replica task for all restored tables
for (Table restoreTbl : restoredTbls) {
for (Table restoreTbl : stagingRestoreTables) {
if (restoreTbl.getType() == TableType.OLAP) {
OlapTable restoreOlapTable = (OlapTable) restoreTbl;
for (Partition restorePart : restoreOlapTable.getPartitions()) {
Expand All @@ -991,6 +994,7 @@ private void checkAndPrepareMeta() {
tableName = tableAliasWithAtomicRestore(tableName);
}
restoreTbl.setName(tableName);
restoredTbls.add(restoreTbl);
}

if (LOG.isDebugEnabled()) {
Expand Down
Loading