Skip to content

branch-4.1: [Refactor](Multi Catalog) Unify external meta cache framework #60937#61725

Open
suxiaogang223 wants to merge 1 commit intoapache:branch-4.1from
suxiaogang223:codex/pick-60937-branch-4.1
Open

branch-4.1: [Refactor](Multi Catalog) Unify external meta cache framework #60937#61725
suxiaogang223 wants to merge 1 commit intoapache:branch-4.1from
suxiaogang223:codex/pick-60937-branch-4.1

Conversation

@suxiaogang223
Copy link
Contributor

Cherry-pick #60937 to branch-4.1

What problem does this PR solve?

Backport the unified external meta cache framework refactor to branch-4.1, aligning external catalog cache lifecycle, routing, invalidation, and engine-specific cache adapters on the shared framework.

Cherry-pick commit

…#60937)

Part of apache#60686

This PR continues the external metadata cache refactor by introducing a
unified engine-scoped cache framework and aligning multiple external
catalog implementations on top of it.

The goal is not to finish every historical cache migration in one shot.
The goal is to make the framework shape explicit and consistent enough
that later migrations can continue on top of one model instead of adding
more engine-specific cache flows.

At a high level, this PR does three things:

- introduces a common framework for external metadata cache lifecycle,
routing, invalidation, and stats
- moves more engine-specific cache behavior behind engine adapters
instead of scattered table- and util-level entry points
- improves cross-engine consistency and test coverage while keeping
legacy compatibility migration incremental

The current framework can be viewed as three layers:

1. manager layer: owns engine cache lifecycle and routes cache
operations
2. engine layer: each engine implements its own cache adapter on the
shared framework
3. catalog/entry layer: each engine keeps per-catalog cache groups and
typed cache entries

```mermaid
flowchart TD
    A["ExternalMetaCacheMgr"] --> B["ExternalMetaCacheRegistry"]
    A --> C["ExternalMetaCacheRouteResolver"]
    A --> D["ExternalMetaCache(engine facade)"]

    D --> E["AbstractExternalMetaCache"]
    E --> F["CatalogEntryGroup(catalog scoped)"]
    F --> G["MetaCacheEntry(table/schema/partition/...)"]

    H["IcebergExternalMetaCache"] --> E
    I["PaimonExternalMetaCache"] --> E
    J["HudiExternalMetaCache"] --> E
    K["MaxComputeExternalMetaCache"] --> E
    L["DorisExternalMetaCache"] --> E
    M["HiveExternalMetaCache"] --> E
```

This structure makes a few framework boundaries explicit:

- manager-level logic is responsible for engine registration, route
resolution, and scoped invalidation dispatch
- engine adapters own engine-specific metadata loading and cache
composition
- shared framework code owns per-catalog entry containers, generic entry
access, and common lifecycle behavior

- add a shared external meta cache framework under
`datasource.metacache`
- refactor `ExternalMetaCacheMgr` so registration and routing are more
explicit instead of staying mixed in one manager path
- make cache initialization and invalidation flow clearer at the
framework level
- align multiple engines with the framework model, including Iceberg,
Paimon, Hudi, MaxCompute, Doris, and Hive
- keep legacy compatibility migration incremental instead of forcing a
one-PR full replacement of every historical cache path
- add or extend framework-level and engine-level tests around routing,
invalidation, and cache behavior

This PR is mainly about pulling different engines closer to one
framework shape.

- Iceberg and Paimon are aligned with the framework while keeping latest
snapshot metadata modeled as table-owned runtime projection
- Hudi moves further away from ad hoc cache state and closer to
framework-owned entry behavior
- MaxCompute and Doris move more cache ownership into engine adapters
- Hive keeps its existing complexity where necessary, but more of that
logic now sits behind the framework-oriented cache layer

The important point is not that every engine is identical now. The
important point is that they are being moved toward one consistent
framework model.

- this is primarily a framework refactor and behavior-alignment change
- migration is still incremental, so some legacy compatibility paths are
intentionally retained
- the purpose of this PR is to reduce structural divergence across
engines without requiring a full one-shot migration

(cherry picked from commit 010f470)
@suxiaogang223 suxiaogang223 requested a review from yiguolei as a code owner March 25, 2026 09:39
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@suxiaogang223
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 0.00% (0/8) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.86% (19596/37071)
Line Coverage 36.22% (182839/504749)
Region Coverage 32.52% (141197/434203)
Branch Coverage 33.72% (61961/183774)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants