foxtail463 commented on code in PR #64160:
URL: https://github.com/apache/doris/pull/64160#discussion_r3759691254
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java:
##########
@@ -208,26 +211,46 @@ public void removeCatalogByEngine(long catalogId, String
engine) {
() -> cache.invalidateCatalog(catalogId)));
}
- public void invalidateDb(long catalogId, String dbName) {
+ public void invalidateDbMetadataCache(long catalogId, String dbName) {
routeCatalogEngines(catalogId, cache -> safeInvalidate(
- cache, catalogId, "invalidateDb", () ->
cache.invalidateDb(catalogId, dbName)));
+ cache, catalogId, "invalidateDbMetadataCache", () ->
cache.invalidateDb(catalogId, dbName)));
// Cache B has no db-scoped eviction key, so a db-level REFRESH drops
ALL entries (coarse but
- // correct -- a rebuild is cheap and lazy). Mirrors invalidateTable's
Cache B wiring.
+ // correct -- a rebuild is cheap and lazy). Mirrors
invalidateTableMetadataCache's Cache B wiring.
invalidateSortedPartitionsCache();
}
- public void invalidateTable(long catalogId, String dbName, String
tableName) {
+ public void invalidateDb(long catalogId, long dbId, String dbName) {
+ invalidateDbMetadataCache(catalogId, dbName);
+ rowCountCache.invalidateDb(catalogId, dbId);
+ }
+
+ public void invalidateDb(ExternalDatabase<?> dorisDb) {
+ invalidateDb(dorisDb.getCatalog().getId(), dorisDb.getId(),
dorisDb.getFullName());
+ }
+
+ public void invalidateTableMetadataCache(long catalogId, String dbName,
String tableName) {
routeCatalogEngines(catalogId, cache -> safeInvalidate(
- cache, catalogId, "invalidateTable",
+ cache, catalogId, "invalidateTableMetadataCache",
() -> cache.invalidateTable(catalogId, dbName, tableName)));
// Also drop the Nereids sorted-partition-ranges cache for this
external table so binary-search
// pruning does not serve ranges older than the refreshed metadata.
- CatalogIf<?> ctl = getCatalog(catalogId);
- if (ctl != null) {
-
Env.getCurrentEnv().getSortedPartitionsCacheManager().invalidateTable(ctl.getName(),
dbName, tableName);
+ CatalogIf<?> catalog = getCatalog(catalogId);
+ if (catalog != null) {
+ Env.getCurrentEnv().getSortedPartitionsCacheManager()
Review Comment:
not introduced by this pr
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -860,22 +862,32 @@ public void truncateTable(String dbName, String
tableName, PartitionNamesInfo pa
// connector-bound handle is remote-resolved), mirroring base
ExternalCatalog.truncateTable.
Env.getCurrentEnv().getRefreshManager().refreshTableInternal(db,
dorisTable, updateTime);
Env.getCurrentEnv().getEditLog().logTruncateTable(
- new TruncateTableInfo(getName(), dbName, tableName,
partitions, updateTime));
+ new TruncateTableInfo(getName(), db.getId(), db.getFullName(),
dorisTable.getId(),
+ dorisTable.getName(), partitions, updateTime));
LOG.info("finished to truncate table {}.{}.{}", getName(), dbName,
tableName);
}
/**
- * Refreshes the local table cache on edit-log replay of a
connector-driven truncate. The base
- * {@link ExternalCatalog#replayTruncateTable} delegates to {@code
metadataOps.afterTruncateTable}, which is a
- * no-op for PluginDriven ({@code metadataOps == null}); this override
re-resolves the cached table by the
- * replayed LOCAL names and runs {@code refreshTableInternal} (the same
effect the master path applied),
- * mirroring legacy {@code HiveMetadataOps.afterTruncateTable}.
+ * Replays cache invalidation for a connector-driven truncate without
loading remote metadata. A cached table
+ * follows the normal refresh path. Otherwise the edit log's exact IDs
invalidate engine and row-count caches,
+ * while connector invalidation widens to the database or catalog scope
when the remote table name is unavailable.
*/
@Override
public void replayTruncateTable(TruncateTableInfo info) {
- getDbForReplay(info.getDb()).ifPresent(db ->
- db.getTableForReplay(info.getTable()).ifPresent(tbl ->
-
Env.getCurrentEnv().getRefreshManager().refreshTableInternal(db, tbl,
info.getUpdateTime())));
+ Optional<ExternalDatabase<? extends ExternalTable>> db =
getDbForReplay(info.getDb());
+ Optional<? extends ExternalTable> table = db.flatMap(database ->
database.getTableForReplay(info.getTable()));
+ if (table.isPresent()) {
+ Env.getCurrentEnv().getRefreshManager()
+ .refreshTableInternal(db.get(), table.get(),
info.getUpdateTime());
+ return;
+ }
+ if (db.isPresent()) {
+ getConnector().invalidateDb(db.get().getRemoteName());
+ } else {
+ invalidateAllConnectorCachesIfPresent();
+ }
+ Env.getCurrentEnv().getExtMetaCacheMgr().invalidateTable(
Review Comment:
就算触发了也只是去掉这个 pr 的效果,不考虑引入兼容代码,一般升级集群都会重启
--
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]