github-actions[bot] commented on code in PR #64043:
URL: https://github.com/apache/doris/pull/64043#discussion_r3345559691
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/PluginDrivenExternalCatalog.java:
##########
@@ -296,6 +300,65 @@ public void gsonPostProcess() throws IOException {
}
}
+ @Override
+ public void createDb(String dbName, boolean ifNotExists, Map<String,
String> properties)
+ throws DdlException {
+ makeSureInitialized();
+ LOG.info("Creating database {} in catalog {} (ifNotExists={})",
dbName, getName(), ifNotExists);
+ HashMap<String, String> props = new HashMap<>(properties);
+ props.put("jdbc_if_not_exists", String.valueOf(ifNotExists));
+ ConnectorSession session = buildConnectorSession();
+
+ // Execute remote CREATE DATABASE
+ connector.getMetadata(session).createDatabase(session, dbName, props);
+
+ // Invalidate cache so next listDatabaseNames() re-fetches from remote
+ resetMetaCacheNames();
+
+ // Write edit log so follower FEs can replay cache invalidation
+ try {
+ Env.getCurrentEnv().getEditLog().logCreateDb(new
CreateDbInfo(getName(), dbName, null));
+ } catch (Exception e) {
+ LOG.warn("Failed to log create database {} in catalog {}.",
dbName, getName(), e);
+ }
+ }
+
+ @Override
+ public void dropDb(String dbName, boolean ifExists, boolean force) throws
DdlException {
+ makeSureInitialized();
+ LOG.info("Dropping database {} from catalog {}", dbName, getName());
+ ConnectorSession session = buildConnectorSession();
+
+ // Execute remote DROP DATABASE
+ connector.getMetadata(session).dropDatabase(session, dbName, ifExists);
+
+ // Remove from cache
+ unregisterDatabase(dbName);
+
+ // Write edit log so follower FEs can replay cache invalidation
+ try {
+ Env.getCurrentEnv().getEditLog().logDropDb(new
DropDbInfo(getName(), dbName));
+ } catch (Exception e) {
+ LOG.warn("Failed to log drop database {} in catalog {}.", dbName,
getName(), e);
+ }
+ }
+
+ @Override
+ public void replayCreateDb(String dbName) {
+ makeSureInitialized();
+ LOG.info("Replay create database {} in catalog {}", dbName, getName());
Review Comment:
`replayCreateDb()`/`replayDropDb()` should not call `makeSureInitialized()`.
Journal replay can run during follower catch-up or FE restart when the external
MySQL/catalog service is unavailable, and `makeSureInitialized()` calls
`initLocalObjects()` plus `buildMetaCache()`, which lists remote databases.
That makes applying a durable CREATE/DROP edit log depend on remote IO and can
abort replay/startup even though replay only needs to adjust local caches.
Existing `ExternalCatalog.replayCreateDb()` avoids initialization and only
invokes the metadata hook if local metadata ops already exist;
`getDbForReplay()` has the same no-remote-call contract. Please keep replay
local, e.g. only invalidate/unregister when `isInitialized()` is true, and do
not create the connector or rebuild remote metadata from replay. This also
applies to `replayDropDb()` below.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]