Repository navigation
Conversation
…nd memory guards - Store only the 36-char entity UUID under om:<ns>:enid:<type>:<fqnHash> and resolve FQN lookups via two single-slot commands (GET :enid: -> HGET :e:<uuid> base), populating the FQN pointer on ID loads too and evicting legacy :en: alongside :enid: and :rn: in one DEL. - Add transparent GZIP+Base64 value compression (om:gz1:) via CacheValueCodec for entity JSON and read bundles above compressionThresholdBytes (default 2048). - Add CacheConfig memory guards: excludedEntityTypes (YAML list or CSV env var), maxEntrySizeBytes, wire unused tagTtlSeconds in CachedTagUsageDao, and downgrade per-write CachedEntityDao INFO logging to DEBUG. - Add EntityCacheBypass.skipPopulate() and use it on createOrUpdate* original lookups (default populateOnUpsert=false) so ingestion sweeps hit warm entries without writing cold misses to Redis. - Add cache.sessionStore (auto|jdbc|redis) in SessionStoreFactory to isolate auth sessions in JDBC when desired, and bound RedisSessionStore per-user ZSET index TTLs monotonically via a single-key Lua script. - Add ADR docs/decisions/2026-11-24-redis-cache-indirection-compression-and-memory-guards.md and unit tests.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Use CacheValueCodec.exceedsMaxEntrySize / encodedByteSize across CachedEntityDao, CachedReadBundle, BundleWarmupBatcher, and CacheWarmupApp so uncompressed non-ASCII values (e.g. CJK descriptions) are checked against UTF-8 byte length rather than UTF-16 char count, while compressed ASCII payloads continue using O(1) String.length().
…default, log level, exclusions, and ZSET TTL
…tagTtlSeconds, and legacy session ZSET TTLs
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findingsChanging Redis/JDBC session storage and index expiry affects authentication-session persistence; backend switches can invalidate active sessions and force users to sign in again. Adds FQN-to-UUID indirection for Redis entity cache keys, GZIP+Base64 value compression, configurable memory guards ( ✅ 1 closed✅ Security: Lua script shortens persistent pre-upgrade user index TTL to one session's
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #38633
Reduce Redis cache memory consumption and protect auth sessions under heavy ingestion workloads via five targeted changes:
:enid:): Store only the 36-char entity UUID underom:<ns>:enid:<type>:<fqnHash>instead of duplicating the full entity JSON under:en:. Name lookups resolve via two single-slot Redis commands (GET :enid:→HGET :e:<uuid> base), preserving cluster-mode hash-slot safety (ADR:2026-10-15-redis-commands-keep-their-keys-in-one-hash-slot). ID-based loads also populate:enid:when:e:succeeds; name invalidations evict:enid:, legacy:en:, and:rn:in oneDELfor rolling-upgrade coherence;EntityLoaderWithNameverifies FQN hash equality to reject stale aliases after renames.om:gz1:): AddCacheValueCodec(JDK built-in GZIP + Base64) for entity JSON andCachedReadBundlevalues at or abovecompressionThresholdBytes(default0on2.1patch releases for silent rolling upgrades/rollbacks; opt in viaCACHE_COMPRESSION_THRESHOLD_BYTES=2048once all pods are upgraded) when compression shrinks the UTF-8 byte length. Readers transparently decode both legacy plain JSON and compressed values, evicting corrupted entries on read.excludedEntityTypes(YAML list or comma-separated env var, extendingUNCACHED_ENTITY_TYPESand skipped byCacheWarmupApp),maxEntrySizeBytes(post-compression cap;0= unlimited; skipped entries do not write dangling:enid:pointers), wire unusedtagTtlSecondsinCachedTagUsageDao(<= 0disables tag caching), and downgrade per-writeCachedEntityDaoINFOlogging toDEBUG.EntityCacheBypass.skipPopulate()and wrap pre-writefindByNameOrNulllookups increateOrUpdate,createOrUpdateForImport, andcreateOrUpdateBatchForImportwhencache.populateOnUpsertisfalse(default). Warm entries still hit Redis and writes still evict stale keys across pods, while cold ingestion sweeps no longer fill Redis with unread entities.cache.sessionStore(auto|jdbc|redis) inSessionStoreFactoryso operators can keep auth sessions in JDBC while using Redismaxmemoryeviction policies, and boundRedisSessionStoreper-user ZSET index TTLs monotonically via a single-key Lua script (ZADD+EXPIREwithout shortening longer sessions).Type of change:
High-level design:
docs/decisions/2026-11-24-redis-cache-indirection-compression-and-memory-guards.md.CacheKeys,CachedEntityDao,EntityRepository(EntityLoaderWithName,EntityLoaderWithId),CacheWarmupApp: FQN→UUID:enid:indirection, write ordering (:e:before:enid:), FQN-match validation on name hit, and rolling-upgrade eviction of:enid:+:en:+:rn:in a singleDEL.CacheValueCodec+CachedEntityDao/CachedReadBundle/BundleWarmupBatcher/CacheWarmupApp: transparent GZIP+Base64 compression withom:gz1:prefix and post-compressionmaxEntrySizeBytescap.CacheConfig,conf/openmetadata.yaml,CachedTagUsageDao,CachedRelationshipDao,EntityCacheBypass:excludedEntityTypes,maxEntrySizeBytes,populateOnUpsert,sessionStore,tagTtlSecondswiring, andEntityCacheBypass.skipPopulate().SessionStoreFactory,RedisSessionStore: explicitjdbc/redis/autosession store mode and single-key Lua scriptZADD_WITH_MAX_TTL_LUAfor monotonic ZSET expiry.:enid:→:e:lookup: rejected becausefqnHashanduuidhash to different Redis Cluster slots (CROSSSLOT, violatesADR:2026-10-15-redis-commands-keep-their-keys-in-one-hash-slot).:en:with format sniffing: rejected because old pods during a rolling deploy would hit Jackson deserialization errors on UUID strings;:enid:keeps rolling deploys clean while deleting legacy:en:on invalidation.CACHE_COMPRESSION_THRESHOLD_BYTES): Defaults to0(disabled) on2.1patch releases so rolling patch upgrades and rollbacks are silent; opt in withCACHE_COMPRESSION_THRESHOLD_BYTES=2048once all pods run a version withom:gz1:decode support.:en:keys: Existing:en:full-JSON keys clear only on next entity write or TTL expiry (48h default). Once all pods are upgraded, operators needing immediate memory reclamation can safely runredis-cli --scan --pattern 'om:prod:en:*' | xargs -r -n 1000 redis-cli UNLINK(adjustingom:prodfor customkeyspace).cache.sessionStore(CACHE_SESSION_STORE): Starts from an empty store; update all pods together and expect one forced sign-in for active users.Tests:
Use cases covered
:enid:UUID pointer to the single JSON copy in:e:, including after an ID-based DB load.om:gz1:and transparently round-trip on ID, FQN, single-bundle, and batch-bundle reads; corrupted entries are evicted on read.maxEntrySizeBytesare skipped without writing dangling:enid:pointers.cache.excludedEntityTypes(via CSV env var or YAML list) bypass Redis caching andCacheWarmupApp.skipPopulate()hit warm Redis entries without writing cold misses back to Redis; concurrent write races evict both:e:and:enid:.CachedTagUsageDaohonorstagTtlSecondsand disables tag caching whentagTtlSeconds <= 0.SessionStoreFactoryhonorscache.sessionStore=jdbc|redis|auto, andRedisSessionStorebounds per-user ZSET index TTLs monotonically on cluster-mode Redis 7.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/cache/CacheValueCodecTest.java(4 tests)openmetadata-service/src/test/java/org/openmetadata/service/cache/CacheConfigTest.java(4 tests)openmetadata-service/src/test/java/org/openmetadata/service/cache/CachedEntityDaoIndirectionTest.java(10 tests)openmetadata-service/src/test/java/org/openmetadata/service/cache/CachedEntityDaoAliasEvictionTest.java(5 tests)openmetadata-service/src/test/java/org/openmetadata/service/cache/CachedMemoryGuardsTest.java(4 tests)openmetadata-service/src/test/java/org/openmetadata/service/cache/BundleWarmupBatcherTest.java(10 tests)openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityLoaderIndirectionTest.java(6 tests)openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/DeferredCacheInvalidationTest.java(7 tests)openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityCacheLoadRaceTest.java(3 tests)openmetadata-service/src/test/java/org/openmetadata/service/security/session/SessionStoreFactoryTest.java(4 tests)openmetadata-service/src/test/java/org/openmetadata/service/security/session/RedisSessionStoreTest.java(20 tests, cluster-mode Redis 7 via Testcontainers)CacheBundleTest(4),CacheWarmupAppConfigParseTest(5),EntityCacheBypassTest(4),EntityRepositoryTagCacheTest(8) — 97/97 passed, 0 failures, 0 errors, 0 skipped.python3 .github/scripts/plan_local_java_tests.py --scope focused): all 12 selected unit test classes ran and passed;.github/java-tests/impact-map.jsonbranch check passed.Backend integration tests
--scope full/ nightly scale & UI ITs) remain pending for merge readiness.Focused unit verification passed on commit
48a23640cc4 (cherry-pick of #38634)(97/97 tests across all 12 impact-mapped unit classes + 3 additional cache/tag test classes, including cluster-mode Redis 7RedisSessionStoreTest). Broader integration tests (--scope full) are pending merge queue / full verification.Ingestion integration tests
Playwright (UI) tests
Not applicable (no UI changes).
Manual testing performed
RedisSessionStoreTest(Testcontainersredis:7-alpine --cluster-enabled yes) confirmingZADD_WITH_MAX_TTL_LUApreserves single-hash-slot execution and monotonic ZSET TTLs.python3 scripts/harness/check_decision_records.py,python3 .github/scripts/plan_local_java_tests.py --check-branch, and pre-commit hooks (mvn spotless:apply/ Java formatting).UI screen recording:
Not applicable — backend Redis cache and configuration changes only; no UI changes.
Checklist:
Fixes 38633: Reduce Redis cache memory via FQN-to-UUID indirection, compression, and memory guardsFixes #38633above.48a23640cc4 (cherry-pick of #38634)) againstREVIEW.mdand confirmed no unresolved 🔴 findings (checked sibling upsert/import/bulk paths, cluster hash-slot compliance, rolling-upgrade eviction coherence, and concurrent write-epoch races).docs/decisions/2026-11-24-redis-cache-indirection-compression-and-memory-guards.mdand verified withscripts/harness/check_decision_records.py.