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

Fix bug that rename table to an existing rollup index name should not be allowed #1150

Merged
merged 2 commits into from
May 13, 2019
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
11 changes: 7 additions & 4 deletions fe/src/main/java/org/apache/doris/backup/BackupHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,12 @@ private void backup(Repository repository, Database db, BackupStmt stmt) throws
ClusterNamespace.getNameFromFullName(db.getFullName()),
tblRefs, stmt.getTimeoutMs(),
catalog, repository.getId());
dbIdToBackupOrRestoreJob.put(db.getId(), backupJob);

// write log
catalog.getEditLog().logBackupJob(backupJob);

// must put to dbIdToBackupOrRestoreJob after edit log, otherwise the state of job may be changed.
dbIdToBackupOrRestoreJob.put(db.getId(), backupJob);

LOG.info("finished to submit backup job: {}", backupJob);
}

Expand All @@ -377,9 +378,11 @@ private void restore(Repository repository, Database db, RestoreStmt stmt) throw
RestoreJob restoreJob = new RestoreJob(stmt.getLabel(), stmt.getBackupTimestamp(),
db.getId(), db.getFullName(), jobInfo, stmt.allowLoad(), stmt.getReplicationNum(),
stmt.getTimeoutMs(), stmt.getMetaVersion(), catalog, repository.getId());
catalog.getEditLog().logRestoreJob(restoreJob);

// must put to dbIdToBackupOrRestoreJob after edit log, otherwise the state of job may be changed.
dbIdToBackupOrRestoreJob.put(db.getId(), restoreJob);

catalog.getEditLog().logRestoreJob(restoreJob);
LOG.info("finished to submit restore job: {}", restoreJob);
}

Expand Down Expand Up @@ -517,7 +520,7 @@ public void replayAddJob(AbstractJob job) {
AbstractJob existingJob = dbIdToBackupOrRestoreJob.get(job.getDbId());
if (existingJob == null || existingJob.isDone()) {
LOG.error("invalid existing job: {}. current replay job is: {}",
existingJob, job);
existingJob, job);
return;
}
// We use replayed job, not the existing job, to do the replayRun().
Expand Down
10 changes: 10 additions & 0 deletions fe/src/main/java/org/apache/doris/catalog/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -4839,6 +4839,16 @@ public void renameTable(Database db, OlapTable table, TableRenameClause tableRen
throw new DdlException("Table name[" + newTableName + "] is already used");
}

// check if rollup has same name
if (table.getType() == TableType.OLAP) {
OlapTable olapTable = (OlapTable) table;
for (String idxName: olapTable.getIndexNameToId().keySet()) {
if (idxName.equals(newTableName)) {
throw new DdlException("New name conflicts with rollup index name: " + idxName);
}
}
}

table.setName(newTableName);

db.dropTable(tableName);
Expand Down