[fix](catalog) do not call makeSureInitialized when create/drop table/db from hms meta event (#21941)
Supplement to #21104
This commit is contained in:
@ -347,13 +347,17 @@ public abstract class ExternalDatabase<T extends ExternalTable>
|
||||
throw new NotImplementedException("dropTable() is not implemented");
|
||||
}
|
||||
|
||||
public void dropTableForReplay(String tableName) {
|
||||
throw new NotImplementedException("replayDropTableFromEvent() is not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatalogIf getCatalog() {
|
||||
return extCatalog;
|
||||
}
|
||||
|
||||
// Only used for sync hive metastore event
|
||||
public void replayCreateTableFromEvent(String tableName, long tableId) {
|
||||
public void createTableForReplay(String tableName, long tableId) {
|
||||
throw new NotImplementedException("createTable() is not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +74,18 @@ public class HMSExternalDatabase extends ExternalDatabase<HMSExternalTable> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replayCreateTableFromEvent(String tableName, long tableId) {
|
||||
public void dropTableForReplay(String tableName) {
|
||||
LOG.debug("replayDropTableFromEvent [{}]", tableName);
|
||||
Long tableId = tableNameToId.remove(tableName);
|
||||
if (tableId == null) {
|
||||
LOG.warn("replayDropTableFromEvent [{}] failed", tableName);
|
||||
return;
|
||||
}
|
||||
idToTbl.remove(tableId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTableForReplay(String tableName, long tableId) {
|
||||
LOG.debug("create table [{}]", tableName);
|
||||
tableNameToId.put(tableName, tableId);
|
||||
HMSExternalTable table = getExternalTable(tableName, tableId, extCatalog);
|
||||
|
||||
@ -49,9 +49,8 @@ public class IcebergExternalDatabase extends ExternalDatabase<IcebergExternalTab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropTable(String tableName) {
|
||||
public void dropTableForReplay(String tableName) {
|
||||
LOG.debug("drop table [{}]", tableName);
|
||||
makeSureInitialized();
|
||||
Long tableId = tableNameToId.remove(tableName);
|
||||
if (tableId == null) {
|
||||
LOG.warn("drop table [{}] failed", tableName);
|
||||
@ -60,7 +59,7 @@ public class IcebergExternalDatabase extends ExternalDatabase<IcebergExternalTab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replayCreateTableFromEvent(String tableName, long tableId) {
|
||||
public void createTableForReplay(String tableName, long tableId) {
|
||||
LOG.debug("create table [{}]", tableName);
|
||||
tableNameToId.put(tableName, tableId);
|
||||
IcebergExternalTable table = new IcebergExternalTable(tableId, tableName, name,
|
||||
|
||||
@ -49,9 +49,8 @@ public class PaimonExternalDatabase extends ExternalDatabase<PaimonExternalTable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropTable(String tableName) {
|
||||
public void dropTableForReplay(String tableName) {
|
||||
LOG.debug("drop table [{}]", tableName);
|
||||
makeSureInitialized();
|
||||
Long tableId = tableNameToId.remove(tableName);
|
||||
if (tableId == null) {
|
||||
LOG.warn("drop table [{}] failed", tableName);
|
||||
@ -60,7 +59,7 @@ public class PaimonExternalDatabase extends ExternalDatabase<PaimonExternalTable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replayCreateTableFromEvent(String tableName, long tableId) {
|
||||
public void createTableForReplay(String tableName, long tableId) {
|
||||
LOG.debug("create table [{}]", tableName);
|
||||
tableNameToId.put(tableName, tableId);
|
||||
PaimonExternalTable table = new PaimonExternalTable(tableId, tableName, name,
|
||||
|
||||
@ -740,7 +740,7 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
|
||||
}
|
||||
db.writeLock();
|
||||
try {
|
||||
db.dropTable(table.getName());
|
||||
db.dropTableForReplay(table.getName());
|
||||
db.setLastUpdateTime(log.getLastUpdateTime());
|
||||
} finally {
|
||||
db.writeUnlock();
|
||||
@ -811,7 +811,7 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
|
||||
}
|
||||
db.writeLock();
|
||||
try {
|
||||
db.replayCreateTableFromEvent(log.getTableName(), log.getTableId());
|
||||
db.createTableForReplay(log.getTableName(), log.getTableId());
|
||||
db.setLastUpdateTime(log.getLastUpdateTime());
|
||||
} finally {
|
||||
db.writeUnlock();
|
||||
@ -857,7 +857,7 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
|
||||
LOG.warn("No db found with id:[{}], it may have been dropped.", log.getDbId());
|
||||
return;
|
||||
}
|
||||
catalog.dropDatabase(db.getFullName());
|
||||
catalog.dropDatabaseForReplay(db.getFullName());
|
||||
Env.getCurrentEnv().getExtMetaCacheMgr().invalidateDbCache(catalog.getId(), db.getFullName());
|
||||
} finally {
|
||||
writeUnlock();
|
||||
@ -898,7 +898,7 @@ public class CatalogMgr implements Writable, GsonPostProcessable {
|
||||
LOG.warn("No catalog found with id:[{}], it may have been dropped.", log.getCatalogId());
|
||||
return;
|
||||
}
|
||||
catalog.createDatabase(log.getDbId(), log.getDbName());
|
||||
catalog.createDatabaseForReplay(log.getDbId(), log.getDbName());
|
||||
} finally {
|
||||
writeUnlock();
|
||||
}
|
||||
|
||||
@ -534,11 +534,11 @@ public abstract class ExternalCatalog
|
||||
dbNameToId.put(ClusterNamespace.getNameFromFullName(db.getFullName()), db.getId());
|
||||
}
|
||||
|
||||
public void dropDatabase(String dbName) {
|
||||
public void dropDatabaseForReplay(String dbName) {
|
||||
throw new NotImplementedException("dropDatabase not implemented");
|
||||
}
|
||||
|
||||
public void createDatabase(long dbId, String dbName) {
|
||||
public void createDatabaseForReplay(long dbId, String dbName) {
|
||||
throw new NotImplementedException("createDatabase not implemented");
|
||||
}
|
||||
|
||||
|
||||
@ -260,9 +260,8 @@ public class HMSExternalCatalog extends ExternalCatalog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropDatabase(String dbName) {
|
||||
public void dropDatabaseForReplay(String dbName) {
|
||||
LOG.debug("drop database [{}]", dbName);
|
||||
makeSureInitialized();
|
||||
Long dbId = dbNameToId.remove(dbName);
|
||||
if (dbId == null) {
|
||||
LOG.warn("drop database [{}] failed", dbName);
|
||||
@ -271,8 +270,7 @@ public class HMSExternalCatalog extends ExternalCatalog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDatabase(long dbId, String dbName) {
|
||||
makeSureInitialized();
|
||||
public void createDatabaseForReplay(long dbId, String dbName) {
|
||||
LOG.debug("create database [{}]", dbName);
|
||||
dbNameToId.put(dbName, dbId);
|
||||
ExternalDatabase<? extends ExternalTable> db = getDbForInit(dbName, dbId, logType);
|
||||
|
||||
Reference in New Issue
Block a user