[fix](restore) fix bug when replay restore and reserve dynamic partition (#17326)

when replay restore a table with reserve_dynamic_partition_enable=true,
must registerOrRemoveDynamicPartitionTable with isReplay=true, or maybe cause
OBSERVER can not replay restore auditlog success.
This commit is contained in:
xueweizhang
2023-03-07 10:13:08 +08:00
committed by GitHub
parent f85f89f240
commit bada731390

View File

@ -1464,7 +1464,7 @@ public class RestoreJob extends AbstractJob {
// set all restored partition version and version hash
// set all tables' state to NORMAL
setTableStateToNormal(db, true);
setTableStateToNormal(db, true, isReplay);
for (long tblId : restoredVersionInfo.rowKeySet()) {
Table tbl = db.getTableNullable(tblId);
if (tbl == null) {
@ -1632,7 +1632,7 @@ public class RestoreJob extends AbstractJob {
Database db = env.getInternalCatalog().getDbNullable(dbId);
if (db != null) {
// rollback table's state to NORMAL
setTableStateToNormal(db, false);
setTableStateToNormal(db, false, isReplay);
// remove restored tbls
for (Table restoreTbl : restoredTbls) {
@ -1709,7 +1709,7 @@ public class RestoreJob extends AbstractJob {
LOG.info("finished to cancel restore job. is replay: {}. {}", isReplay, this);
}
private void setTableStateToNormal(Database db, boolean committed) {
private void setTableStateToNormal(Database db, boolean committed, boolean isReplay) {
for (String tableName : jobInfo.backupOlapTableObjects.keySet()) {
Table tbl = db.getTableNullable(jobInfo.getAliasByOriginNameIfSet(tableName));
if (tbl == null) {
@ -1743,7 +1743,7 @@ public class RestoreJob extends AbstractJob {
}
if (committed && reserveDynamicPartitionEnable) {
if (DynamicPartitionUtil.isDynamicPartitionTable(tbl)) {
DynamicPartitionUtil.registerOrRemoveDynamicPartitionTable(db.getId(), olapTbl, false);
DynamicPartitionUtil.registerOrRemoveDynamicPartitionTable(db.getId(), olapTbl, isReplay);
Env.getCurrentEnv().getDynamicPartitionScheduler().createOrUpdateRuntimeInfo(tbl.getId(),
DynamicPartitionScheduler.LAST_UPDATE_TIME, TimeUtils.getCurrentFormatTime());
}