diff --git a/fe/src/main/java/org/apache/doris/backup/BackupHandler.java b/fe/src/main/java/org/apache/doris/backup/BackupHandler.java index 806e521a203a05..9014d6c4782d9b 100644 --- a/fe/src/main/java/org/apache/doris/backup/BackupHandler.java +++ b/fe/src/main/java/org/apache/doris/backup/BackupHandler.java @@ -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); } @@ -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); } @@ -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(). diff --git a/fe/src/main/java/org/apache/doris/catalog/Catalog.java b/fe/src/main/java/org/apache/doris/catalog/Catalog.java index 17de41452519ce..4f2889a8aab9ba 100644 --- a/fe/src/main/java/org/apache/doris/catalog/Catalog.java +++ b/fe/src/main/java/org/apache/doris/catalog/Catalog.java @@ -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);