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

Also fix another bug that backup/restore job should add to task map after writing edit log.
ISSUE: #522
This commit is contained in:
Mingyu Chen
2019-05-13 17:10:51 +08:00
committed by GitHub
parent ffe3eaa1a7
commit 559db490e0
2 changed files with 17 additions and 4 deletions

View File

@ -349,11 +349,12 @@ public class BackupHandler extends Daemon implements Writable {
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);
}
@ -377,9 +378,11 @@ public class BackupHandler extends Daemon implements Writable {
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);
}
@ -517,7 +520,7 @@ public class BackupHandler extends Daemon implements Writable {
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().

View File

@ -4839,6 +4839,16 @@ public class Catalog {
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);