github-actions[bot] commented on code in PR #63612:
URL: https://github.com/apache/doris/pull/63612#discussion_r4488328455
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalMetaCacheMgr.java:
##########
@@ -240,14 +240,24 @@ public void prepareCatalogByEngine(long catalogId, String
engine) {
}
public void invalidateCatalog(long catalogId) {
+ CatalogIf<?> catalog = getCatalog(catalogId);
+ invalidateCatalogCaches(catalogId, catalog == null ? null :
catalog.getName(), "invalidateCatalog",
+ cache -> cache.invalidateCatalogEntries(catalogId));
+ }
+
+ private void invalidateCatalogCaches(long catalogId, String catalogName,
String operation,
+ Consumer<ExternalMetaCache> invalidation) {
try {
try {
routeCatalogEngines(catalogId, cache -> safeInvalidate(
- cache, catalogId, "invalidateCatalog",
- () -> cache.invalidateCatalogEntries(catalogId)));
+ cache, catalogId, operation, () ->
invalidation.accept(cache)));
} finally {
- // This cache has no catalog-scoped key, so catalog
invalidation must clear it globally.
- invalidateSortedPartitionsCache();
+ if (catalogName != null) {
+ Env.getCurrentEnv().onCatalogChanged(catalogName);
Review Comment:
[P1] Avoid taking the MV write lock while retiring a catalog
`ExternalCatalog.resetToUninitialized()` calls `removeCatalog(id, name)`
from `detachRuntimeAndRetireCaches()` while holding the catalog monitor. This
new `onCatalogChanged()` callback reaches `MTMV.invalidateRewriteCache()` and
waits for the MV write lock. Concurrently,
`CollectRelation.collectMTMVCandidates()` holds that MV's read lock while
`StatementContext.getAndCacheTable(..., TableFrom.MTMV, ...)` resolves an
external base through `getDbNullable()` -> synchronized
`makeSureInitialized()`. If an `ALTER CATALOG` reset acquires the catalog
monitor between those steps, the query waits for the catalog monitor and the
reset waits for the MV lock indefinitely. The MTMV table map is separate from
the query table map, so even a single already-resolved external base takes this
path. Resolve copied MV dependency identities outside the MV lock, or perform
the MTMV invalidation after releasing the catalog monitor while preserving the
generation barrier.
--
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]