yuqi1129 opened a new pull request, #12111: URL: https://github.com/apache/gravitino/pull/12111
> **Stacked on #12042** (`issue-12018-cache-type-allowlist`). Please merge after #12042; until then this PR's diff also contains #12042's commits. ### What changes were proposed in this pull request? Make the default `caffeine` entity store cache correct in multi-node deployments by reusing the existing `entity_change_log` + `EntityChangeLogPoller`, per the #11923 design (Phase 1 of #11737). - **Coherence marker**: add `EntityCache.coherence()` → `LOCAL_PER_NODE | SHARED` (`cache/Coherence.java`); `BaseEntityCache` defaults to `LOCAL_PER_NODE`, so `caffeine` is per-node. A future Redis cache reports `SHARED`. - **Reader side**: new `EntityCacheChangeLogListener` replays each ALTER/DROP row as `invalidate(ident, type)`; a container drop cascades to cached children via the existing forward `cacheIndex` prefix scan. Registered as a third poller consumer (next to the catalog and jcasbin id-mapping caches) **only when** `coherence() == LOCAL_PER_NODE` — the coherence gate. - **Writer side**: add in-transaction change-log emit points for the cached types that had none — `TagMetaService` (update/delete), `PolicyMetaService` (update/delete), `JobMetaService` (overwrite/delete). Structural rows already exist. ### Why are the changes needed? Today only the writing node invalidates its cache, so other nodes serve stale data until TTL expiry — forcing `gravitino.cache.enabled=false` in HA deployments. This reuses infrastructure already present (no schema change, no new dependency), so `cache.enabled=true` becomes safe across nodes with the default cache. Fix: #12019 ### Does this PR introduce _any_ user-facing change? No. Internal caching behavior only; uncached types and single-node behavior are unchanged. ### How was this patch tested? - `TestEntityCacheChangeLogListener` — dispatch/cascade/sibling-preservation, per-type invalidation, malformed-row skipping, fault isolation, coherence values. - `TestEntityChangeLogService` — the new tag/policy/job ALTER & DROP rows are emitted (a plain create emits none). - `TestEntityCacheCrossNodeInvalidation` — end-to-end: a node A write emits a change-log row and node B's poller invalidates its own cache (table ALTER and schema-drop child cascade). - Regression: `org.apache.gravitino.cache.*`, `TestEntityChangeLogPoller`, `TestTagMetaService`, `TestPolicyMetaService`, `TestJobMetaService`, `TestRelationalEntityStore` all pass; `spotlessCheck` and `javadoc` are clean. -- 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]
