[fix](fe) Fix drop table write too many times editlog (#29966)

This commit is contained in:
Lei Zhang
2024-01-17 16:40:17 +08:00
committed by yiguolei
parent d4195b3cc0
commit e73c0f4077
3 changed files with 12 additions and 15 deletions

View File

@ -903,11 +903,15 @@ public class InternalCatalog implements CatalogIf<Database> {
} finally {
table.writeUnlock();
}
DropInfo info = new DropInfo(db.getId(), table.getId(), tableName, -1L, stmt.isForceDrop(), recycleTime);
Env.getCurrentEnv().getEditLog().logDropTable(info);
Env.getCurrentEnv().getQueryStats().clear(Env.getCurrentEnv().getCurrentCatalog().getId(),
db.getId(), table.getId());
Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
DropInfo info = new DropInfo(db.getId(), table.getId(), tableName, -1L, stmt.isForceDrop(), recycleTime);
Env.getCurrentEnv().getEditLog().logDropTable(info);
Env.getCurrentEnv().getMtmvService().dropTable(table);
} catch (UserException e) {
throw new DdlException(e.getMessage(), e.getMysqlErrorCode());
@ -944,6 +948,7 @@ public class InternalCatalog implements CatalogIf<Database> {
unprotectDropTable(db, table, isForceDrop, true, recycleTime);
Env.getCurrentEnv().getQueryStats().clear(Env.getCurrentInternalCatalog().getId(), db.getId(),
tableId);
Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
} finally {
table.writeUnlock();
db.writeUnlock();

View File

@ -1135,7 +1135,9 @@ public class EditLog {
break;
}
case OperationType.OP_DELETE_TABLE_STATS: {
env.getAnalysisManager().replayTableStatsDeletion((TableStatsDeletionLog) journal.getData());
long tableId = ((TableStatsDeletionLog) journal.getData()).id;
LOG.info("replay delete table stat tableId: {}", tableId);
Env.getCurrentEnv().getAnalysisManager().removeTableStats(tableId);
break;
}
case OperationType.OP_ALTER_MTMV: {

View File

@ -46,7 +46,6 @@ import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.CatalogIf;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.persist.AnalyzeDeletionLog;
import org.apache.doris.persist.TableStatsDeletionLog;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ShowResultSet;
@ -1015,17 +1014,8 @@ public class AnalysisManager implements Writable {
}
}
public void removeTableStats(long tblId) {
if (!idToTblStats.containsKey(tblId)) {
return;
}
TableStatsDeletionLog log = new TableStatsDeletionLog(tblId);
Env.getCurrentEnv().getEditLog().logDeleteTableStats(log);
replayTableStatsDeletion(log);
}
public void replayTableStatsDeletion(TableStatsDeletionLog log) {
idToTblStats.remove(log.id);
public void removeTableStats(long tableId) {
idToTblStats.remove(tableId);
}
public ColStatsMeta findColStatsMeta(long tblId, String colName) {