cherry pick from #37488
This commit is contained in:
@ -973,13 +973,13 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void dropTable(Database db, long tableId, boolean isForceDrop,
|
||||
private void dropTable(Database db, long tableId, boolean isForceDrop, boolean isReplay,
|
||||
Long recycleTime) throws MetaNotFoundException {
|
||||
Table table = db.getTableOrMetaException(tableId);
|
||||
db.writeLock();
|
||||
table.writeLock();
|
||||
try {
|
||||
unprotectDropTable(db, table, isForceDrop, true, recycleTime);
|
||||
unprotectDropTable(db, table, isForceDrop, isReplay, recycleTime);
|
||||
Env.getCurrentEnv().getQueryStats().clear(Env.getCurrentInternalCatalog().getId(), db.getId(), tableId);
|
||||
Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
|
||||
} finally {
|
||||
@ -990,7 +990,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
|
||||
public void replayDropTable(Database db, long tableId, boolean isForceDrop,
|
||||
Long recycleTime) throws MetaNotFoundException {
|
||||
dropTable(db, tableId, isForceDrop, recycleTime);
|
||||
dropTable(db, tableId, isForceDrop, true, recycleTime);
|
||||
}
|
||||
|
||||
public void replayEraseTable(long tableId) {
|
||||
@ -2639,6 +2639,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
// if failed in any step, use this set to do clear things
|
||||
Set<Long> tabletIdSet = new HashSet<>();
|
||||
// create partition
|
||||
boolean hadLogEditCreateTable = false;
|
||||
try {
|
||||
if (partitionInfo.getType() == PartitionType.UNPARTITIONED) {
|
||||
if (storagePolicy.equals("") && properties != null && !properties.isEmpty()) {
|
||||
@ -2762,11 +2763,6 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
if (!result.first) {
|
||||
ErrorReport.reportDdlException(ErrorCode.ERR_TABLE_EXISTS_ERROR, tableName);
|
||||
}
|
||||
if (DebugPointUtil.isEnable("FE.createOlapTable.exception")) {
|
||||
LOG.info("debug point FE.createOlapTable.exception, throw e");
|
||||
// not commit, not log edit
|
||||
throw new DdlException("debug point FE.createOlapTable.exception");
|
||||
}
|
||||
|
||||
if (result.second) {
|
||||
if (Env.getCurrentColocateIndex().isColocateTable(tableId)) {
|
||||
@ -2779,6 +2775,9 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
}
|
||||
LOG.info("duplicate create table[{};{}], skip next steps", tableName, tableId);
|
||||
} else {
|
||||
// if table not exists, then db.createTableWithLock will write an editlog.
|
||||
hadLogEditCreateTable = true;
|
||||
|
||||
// we have added these index to memory, only need to persist here
|
||||
if (Env.getCurrentColocateIndex().isColocateTable(tableId)) {
|
||||
GroupId groupId = Env.getCurrentColocateIndex().getGroup(tableId);
|
||||
@ -2797,17 +2796,27 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
.createOrUpdateRuntimeInfo(tableId, DynamicPartitionScheduler.LAST_UPDATE_TIME,
|
||||
TimeUtils.getCurrentFormatTime());
|
||||
}
|
||||
|
||||
if (DebugPointUtil.isEnable("FE.createOlapTable.exception")) {
|
||||
LOG.info("debug point FE.createOlapTable.exception, throw e");
|
||||
throw new DdlException("debug point FE.createOlapTable.exception");
|
||||
}
|
||||
} catch (DdlException e) {
|
||||
LOG.warn("create table failed {} - {}", tabletIdSet, e.getMessage());
|
||||
for (Long tabletId : tabletIdSet) {
|
||||
Env.getCurrentInvertedIndex().deleteTablet(tabletId);
|
||||
}
|
||||
// only remove from memory, because we have not persist it
|
||||
// edit log write DropTableInfo will result in deleting colocate group,
|
||||
// but follow fe may need wait 30s (recycle bin mgr run every 30s).
|
||||
if (Env.getCurrentColocateIndex().isColocateTable(tableId)) {
|
||||
Env.getCurrentColocateIndex().removeTable(tableId);
|
||||
}
|
||||
try {
|
||||
dropTable(db, tableId, true, 0L);
|
||||
dropTable(db, tableId, true, false, 0L);
|
||||
if (hadLogEditCreateTable) {
|
||||
DropInfo info = new DropInfo(db.getId(), tableId, olapTable.getName(), -1L, true, 0L);
|
||||
Env.getCurrentEnv().getEditLog().logDropTable(info);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("drop table", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user