-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[refactor](paimon) Per-catalog Paimon metadata cache with two-level table+snapshot structure #60478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refactor](paimon) Per-catalog Paimon metadata cache with two-level table+snapshot structure #60478
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run external |
FE Regression Coverage ReportIncrement line coverage |
|
run external |
FE Regression Coverage ReportIncrement line coverage |
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
Outdated
Show resolved
Hide resolved
|
run buildall |
TPC-H: Total hot run time: 29989 ms |
ClickBench: Total hot run time: 28.18 s |
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
What problem does this PR solve?
Summary
Refactor Paimon metadata cache from a single global instance to per-catalog instances,
introduce a two-level Table+Snapshot cache structure, and unify TTL resolution logic
across Iceberg/Paimon/Schema caches.
Motivation
The previous design shared a single
PaimonMetadataCacheinstance and a single globalsnapshotCacheacross all Paimon catalogs. This caused:catalogIdfor isolation; invalidation required scanning allkeys and filtering.
PaimonExternalTableeagerly fetched theTableobject at construction time, incurringremote calls even when the table was never subsequently accessed.
Changes
Per-catalog cache instantiation
CatalogScopedCacheMgr<T>, a generic catalog-keyed cache manager backed byConcurrentHashMap.computeIfAbsent.PaimonMetadataCacheMgrnow extendsCatalogScopedCacheMgr<PaimonMetadataCache>;each catalog owns an independent
PaimonMetadataCache.icebergCacheMap(previously hand-rolled double-checked locking)in
ExternalMetaCacheMgrto the sameCatalogScopedCacheMgr.Two-level table + snapshot cache
snapshotCachewithtableCache(key:
PaimonTableCacheKey, value:PaimonTableCacheValue).PaimonTableCacheValueholds the PaimonTableobject and lazy-loadsPaimonSnapshotCacheValuevia double-checked locking.Tableobject is managed by CaffeineLoadingCache, subject to TTL/maxSize.When TTL expires, Caffeine creates a new
PaimonTableCacheValue, and the snapshotis re-lazily-loaded on next access.
tableCachedirectly; MTMV queries go through the explicitsnapshot path; branch queries call the Paimon catalog directly (branches have
independent schemas, not suitable for the main table cache).
Unified TTL resolution
ExternalCatalog.resolveCacheTtlSpec()to centralize TTL property parsing:null→ use global default (external_cache_expire_time_seconds_after_access)-1→ no expiry (Caffeine does not setexpireAfterAccess)0→ disable cache (maxSize=0, Caffeine evicts immediately)>0→ use asexpireAfterAccessIcebergMetadataCache,PaimonMetadataCache, andExternalSchemaCache.paimon.table.meta.cache.ttl-secondcatalog property with validation incheckProperties().ALTER CATALOG SETtriggers cache reinitialization vianotifyPropertiesUpdated(), consistent with Iceberg's existing pattern.Lazy table access in PaimonExternalTable
paimonTablefield from the constructor.Tableobject access now goes throughPaimonUtils→PaimonMetadataCache.tableCache, making it lazy and cache-aware.PaimonUtilsas the centralized static accessor for Paimon cacheoperations, simplifying call sites.
Iceberg invalidation fast path
IcebergMetadataCache.invalidateTableCache()now attempts a direct key lookup(
getIfPresent) first. On hit, invalidate immediately; on miss, fall back to fullcache scan matching by local name. Avoids unnecessary iteration on the common path.
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)