Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public Pair<Boolean, Boolean> createTableWithoutLock(
registerTable(table);
if (!isReplay) {
// Write edit log
CreateTableInfo info = new CreateTableInfo(fullQualifiedName, table);
CreateTableInfo info = new CreateTableInfo(fullQualifiedName, id, table);
Env.getCurrentEnv().getEditLog().logCreateTable(info);
}
} finally {
Expand Down
4 changes: 2 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -4165,8 +4165,8 @@ public static void getDdlStmt(DdlStmt ddlStmt, String dbName, TableIf table, Lis
}
}

public void replayCreateTable(String dbName, Table table) throws MetaNotFoundException {
getInternalCatalog().replayCreateTable(dbName, table);
public void replayCreateTable(String dbName, long dbId, Table table) throws MetaNotFoundException {
getInternalCatalog().replayCreateTable(dbName, dbId, table);
}

public void replayAlterExternalTableSchema(String dbName, String tableName, List<Column> newSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1475,8 +1475,18 @@ public void createTableAsSelect(CreateTableAsSelectStmt stmt) throws DdlExceptio
}
}

public void replayCreateTable(String dbName, Table table) throws MetaNotFoundException {
Database db = this.fullNameToDb.get(dbName);
public void replayCreateTable(String dbName, long dbId, Table table) throws MetaNotFoundException {
if (dbId != -1L) {
Database db = getDbOrMetaException(dbId);
replayCreateTableInternal(db, table);
} else {
// Compatible with old logic
Database db = getDbOrMetaException(dbName);
replayCreateTableInternal(db, table);
}
}

private void replayCreateTableInternal(Database db, Table table) throws MetaNotFoundException {
try {
db.createTableWithLock(table, true, false);
} catch (DdlException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
public class CreateTableInfo implements Writable, GsonPostProcessable {
public static final Logger LOG = LoggerFactory.getLogger(CreateTableInfo.class);

@SerializedName(value = "dbId")
private long dbId = -1L;
@SerializedName(value = "dbName")
private String dbName;
@SerializedName(value = "table")
Expand All @@ -47,7 +49,9 @@ public CreateTableInfo() {
// for persist
}

public CreateTableInfo(String dbName, Table table) {
// for internal table
public CreateTableInfo(String dbName, long dbId, Table table) {
this.dbId = dbId;
this.dbName = dbName;
this.table = table;
}
Expand All @@ -56,6 +60,10 @@ public String getDbName() {
return dbName;
}

public long getDbId() {
return dbId;
}

public Table getTable() {
return table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static void loadJournal(Env env, Long logId, JournalEntity journal) {
LOG.info("Begin to unprotect create table. db = " + info.getDbName() + " table = " + info.getTable()
.getId());
CreateTableRecord record = new CreateTableRecord(logId, info);
env.replayCreateTable(info.getDbName(), info.getTable());
env.replayCreateTable(info.getDbName(), info.getDbId(), info.getTable());
env.getBinlogManager().addCreateTableRecord(record);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testSerialization() throws Exception {
TStorageType.COLUMN, KeysType.AGG_KEYS);
Deencapsulation.setField(table, "baseIndexId", 1000);
table.addPartition(partition);
CreateTableInfo info = new CreateTableInfo("db1", table);
CreateTableInfo info = new CreateTableInfo("db1", -1L, table);
info.write(dos);

dos.flush();
Expand Down