Skip to content

Cache audit fixes: tag rename + relationship invalidation, bundle warmup - #27864

Merged
harshach merged 5 commits into
mainfrom
harshach/cache-fixes-warmup
May 2, 2026
Merged

harshach merged 5 commits into
mainfrom
harshach/cache-fixes-warmup

Conversation

@harshach

@harshach harshach commented May 2, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes:

Audited the Redis-backed cache layer and shipped two write-through correctness fixes plus warmup enhancements. Bug A: Tag/Glossary/Classification rename now invalidates cached entity JSON for every entity tagged with the renamed tag, using the search index (mirrors the existing updateClassificationTagByFqnPrefix fanout pattern). Bug B: addRelationship / deleteRelationship and bulk variants now invalidate the cached bundle on both sides; non-cacheable types (Bot/Domain/DataProduct/Task/etc.) short-circuit so cascade-heavy delete paths don't pay for Redis ops on keys that were never written. Warmup: new BundleWarmupBatcher pre-warms tags + certification using batched tag_usage queries; CacheWarmupApp adds checkpoint resume, opt-in SETNX-based distributed claim, and per-entity-type cache.warmup.coverage gauges. Tests: BundleWarmupBatcherTest (mocked unit), TagRenameCacheIT and RelationshipCacheInvalidationIT (Redis-gated end-to-end).

Type of change:

  • Bug fix
  • Improvement

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests that cover the exact scenarios we are fixing.
  • For JSON Schema changes: dropped unused consumerThreads and queueSize fields from cacheWarmupAppConfig.json (they were dead config — runtime had already migrated off the producer/consumer queue design); added warmBundles and enableDistributedClaim flags. No migration needed since the removed fields were never consumed.

🤖 Generated with Claude Code

…, bundle warmup

Fix two write-through cache correctness bugs and enhance the warmup app:

Bug A — Tag/Glossary/Classification rename now invalidates the cached entity
JSON for every entity tagged with the renamed tag. Adds
invalidateCacheForTaggedEntities helpers in EntityRepository that use the
search index (same source updateClassificationTagByFqnPrefix already uses) to
enumerate affected entities, then call invalidateCacheForEntity for each.
Wired into TagRepository, ClassificationRepository, and both rename + parent-
move paths in GlossaryTermRepository.

Bug B — Direct addRelationship/deleteRelationship and bulk variants now
invalidate the cached bundle/owners/domains on both sides. Bot/Domain/Data
Product (already in UNCACHED_ENTITY_TYPES) short-circuit in
invalidateCacheForEntity so cascade-heavy delete paths don't pay for Redis
ops on keys that were never written.

Warmup enhancements — new BundleWarmupBatcher pre-warms the per-entity bundle
cache (tags + certification) using batched tag_usage queries; relations stay
lazy. CacheWarmupApp adds per-entity-type checkpoint resume, opt-in
SETNX-based distributed claim for multi-instance deploys, and per-entity-type
cache.warmup.coverage / cache.warmup.bundle.coverage gauges. CacheProvider
gains scanCount; CacheMetrics gains coverage gauges and a completed_runs
counter. cacheWarmupAppConfig.json drops dead consumerThreads/queueSize and
adds warmBundles + enableDistributedClaim flags.

Tests — BundleWarmupBatcherTest covers the batcher with mocked DAO/cache.
TagRenameCacheIT and RelationshipCacheInvalidationIT cover the bug fixes
end-to-end under the cache-tests / postgres-os-redis profile.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 2, 2026 15:46
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels May 2, 2026
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

@github-actions
github-actions Bot requested a review from a team as a code owner May 2, 2026 15:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR audits and tightens correctness of the Redis-backed cache layer by ensuring caches are invalidated on tag/glossary/classification renames and relationship mutations, and by enhancing cache warmup with bundle pre-warming and new operational metrics/controls.

Changes:

  • Invalidate cached entities/bundles for all entities tagged with a renamed Tag/GlossaryTerm/Classification (search-index fanout).
  • Invalidate cache on both sides for relationship add/delete (including bulk variants) and short-circuit Redis ops for explicitly uncached entity types.
  • Enhance CacheWarmup with bundle pre-warm batching, checkpoint resume, optional distributed claiming, and warmup coverage metrics; add unit + Redis-gated IT coverage.

Reviewed changes

Copilot reviewed 13 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
openmetadata-spec/src/main/resources/json/schema/entity/applications/configuration/internal/cacheWarmupAppConfig.json Updates warmup config schema (batch default, bundle warmup + distributed claim flags).
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java Adds search-based tagged-entity invalidation helpers; relationship mutation invalidation; skip Redis invalidation for uncached types.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TagRepository.java Ensures tag rename also invalidates caches for tagged entities.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/GlossaryTermRepository.java Ensures glossary term rename/move invalidates caches for tagged entities.
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationRepository.java Ensures classification rename invalidates caches for entities tagged under the classification.
openmetadata-service/src/main/java/org/openmetadata/service/cache/CacheProvider.java Adds scanCount capability (default unsupported).
openmetadata-service/src/main/java/org/openmetadata/service/cache/RedisCacheProvider.java Implements scanCount via Redis SCAN.
openmetadata-service/src/main/java/org/openmetadata/service/cache/CacheMetrics.java Adds warmup run + per-entity-type coverage gauges.
openmetadata-service/src/main/java/org/openmetadata/service/cache/BundleWarmupBatcher.java New batcher to pre-warm bundle keys with tags + certification.
openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java Adds checkpoint resume, optional distributed claim, bundle warmup integration, and coverage reporting.
openmetadata-service/src/test/java/org/openmetadata/service/cache/BundleWarmupBatcherTest.java Unit tests for bundle warmup batching behavior.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/cache/TagRenameCacheIT.java Redis-gated end-to-end test for tag-rename invalidation.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/cache/RelationshipCacheInvalidationIT.java Redis-gated end-to-end test for relationship invalidation correctness.

Six follow-ups against PR #27864:

- releaseClaim now does a compare-and-delete: GET the owner first and only
  DEL when it matches our instanceId. Previously a 10-min TTL could expire
  mid-warm, another instance could claim, and we'd blindly delete its lock.
- warmBundles / enableDistributedClaim are now read from the user-supplied
  app config map (matching the cacheWarmupAppConfig.json schema fields)
  instead of being JVM-system-property-only. System properties remain a
  fallback for bootstrap / unedited records.
- Per-entity-type checkpoint and claim keys now embed cacheConfig.redis
  .keyspace so two environments sharing one Redis with different keyspaces
  no longer collide on warmup metadata.
- reportCoverage now prefers scanCount over current-run success delta when
  available, so resumed runs report end-state coverage instead of the
  artificially low partial number.
- CacheWarmupApp class Javadoc updated to reflect that bundle pre-warm is
  on by default; intentionally-not-done text was stale.
- RelationshipCacheInvalidationIT Javadoc clarifies that the assertion is
  on the cacheable table side; Domain itself is in UNCACHED_ENTITY_TYPES.
- CacheProvider.scanCount Javadoc documents the O(DBSIZE) cost so callers
  don't drop it on the request path.
- EntityRepository.invalidateCacheForTaggedEntities Javadoc strengthens
  the search-lag tradeoff section with the actual fallback (entity TTL).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
readAppConfigFlags previously only accepted Boolean.TRUE / Boolean.FALSE.
Depending on how the app config arrives (typed POJO, raw JSON, YAML
env-var override, API string body) the same logical value can land as a
"true"/"false" string — and the instanceof Boolean check would silently
ignore it and fall back to the JVM system property. Operators setting the
flag in the UI would see no effect. Added a small parseBooleanFlag helper
that handles both shapes.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 2, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 22 changed files in this pull request and generated 6 comments.

Comment on lines +3025 to +3068
int total = 0;
for (String fqn : tagFqns) {
total += invalidateCacheForTaggedEntities(fqn);
}
if (total > 0) {
LOG.info(
"Invalidated cache for {} entities across {} renamed tag FQNs", total, tagFqns.size());
}
return total;
}

/**
* Convenience wrapper for tag-like entity renames (Tag, GlossaryTerm) where the rename cascades
* to descendants in the same entity table. Enumerates the descendant FQNs from the entity DAO
* BEFORE the DB rename rewrites them, then invalidates cached entities tagged with the prefix or
* any descendant. For Classification (where children live in a different entity table), enumerate
* child tag FQNs at the call site and pass them to {@link
* #invalidateCacheForTaggedEntities(Collection)} directly.
*/
public static int invalidateCacheForTaggedEntitiesAndDescendants(
String entityType, String oldPrefix) {
if (entityType == null || nullOrEmpty(oldPrefix)) {
return 0;
}
List<String> fqns = new ArrayList<>();
fqns.add(oldPrefix);
try {
EntityRepository<?> repo = Entity.getEntityRepository(entityType);
if (repo != null && repo.getDao() != null) {
List<EntityDAO.EntityIdFqnPair> descendants =
repo.getDao().listDescendantIdFqnByPrefix(oldPrefix);
for (EntityDAO.EntityIdFqnPair pair : descendants) {
if (pair.fqn != null && !pair.fqn.equals(oldPrefix)) {
fqns.add(pair.fqn);
}
}
}
} catch (Exception e) {
LOG.warn(
"Failed to enumerate descendants for tagged-entity invalidation: type={} fqn={}",
entityType,
oldPrefix,
e);
}
Comment on lines +2996 to +3001
List<EntityReference> page;
try {
page =
ReindexingUtil.findReferenceInElasticSearchAcrossAllIndexes(
"tags.tagFQN", ReindexingUtil.escapeDoubleQuotes(tagFqn), from);
} catch (Exception e) {
…failures

Four follow-ups from the second Copilot review pass:

- writeCheckpoint now only advances when the bundle pre-warm succeeded for
  at least some rows. A whole-page bundle failure (Redis pipeline timeout
  or tag_usage query error) holds the checkpoint so the next run retries
  the page. Partial bundle failure still advances since the entity JSON
  is warm and most bundles landed.
- Added refreshClaim — compare-and-set extension of the per-entity-type
  claim TTL after every successful page. Large entity types can outlast
  CLAIM_TTL (10 min); without refresh another instance could acquire
  mid-warm. Compare-and-set prevents stomping on a successor that
  legitimately took over after we lost our claim.
- BundleWarmupBatcher per-row failures now log the entity type + id at
  debug. Previously the catch swallowed details and made bundle DTO /
  serialization issues invisible.
- Removed the BundleWarmupBatcherTest typeCompatibility test that only
  existed to keep the EntityInterface import live.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Comment on lines +423 to +437
private void refreshClaim(String entityType) {
if (!enableDistributedClaim
|| cacheProvider == null
|| !cacheProvider.available()
|| claimKeyPrefix == null) {
return;
}
String key = claimKeyPrefix + entityType;
try {
String owner = cacheProvider.get(key).orElse(null);
if (instanceId.equals(owner)) {
cacheProvider.set(key, instanceId, CLAIM_TTL);
}
} catch (Exception e) {
LOG.debug("Failed to refresh claim for {}", entityType, e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Edge Case: refreshClaim has TOCTOU race between GET and SET

The refreshClaim method reads the current owner via GET, then conditionally writes back with SET — these two calls are not atomic. Between the GET and SET another instance could acquire the claim (if the TTL just expired), and the SET would silently overwrite the new owner's lock.

The Javadoc acknowledges the non-atomicity and argues the consequence is only redundant work (Redis writes are idempotent). This is a fair assessment — the claim is an optimization, not a correctness lock — so the impact is limited to occasional duplicate warmup work rather than data corruption. Still, a Lua script (if redis.call('get',KEYS[1])==ARGV[1] then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) end) would close the window cleanly, similar to the well-known Redlock refresh pattern.

Suggested fix:

Add a compareAndSet (or setIfEquals) method to CacheProvider
backed by a Lua script:
  String lua = "if redis.call('get',KEYS[1])==ARGV[1] "
             + "then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) "
             + "else return nil end";
Then call it here instead of the GET+SET pair.

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

@gitar-bot

gitar-bot Bot commented May 2, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 5 resolved / 6 findings

Implements Redis-backed cache invalidation for tag renames and relationship updates while adding a robust, checkpoint-aware bundle warmup mechanism. Address the TOCTOU race condition in refreshClaim by using an atomic operation to prevent concurrent owner conflicts.

💡 Edge Case: refreshClaim has TOCTOU race between GET and SET

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java:423-437

The refreshClaim method reads the current owner via GET, then conditionally writes back with SET — these two calls are not atomic. Between the GET and SET another instance could acquire the claim (if the TTL just expired), and the SET would silently overwrite the new owner's lock.

The Javadoc acknowledges the non-atomicity and argues the consequence is only redundant work (Redis writes are idempotent). This is a fair assessment — the claim is an optimization, not a correctness lock — so the impact is limited to occasional duplicate warmup work rather than data corruption. Still, a Lua script (if redis.call('get',KEYS[1])==ARGV[1] then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) end) would close the window cleanly, similar to the well-known Redlock refresh pattern.

Suggested fix
Add a compareAndSet (or setIfEquals) method to CacheProvider
backed by a Lua script:
  String lua = "if redis.call('get',KEYS[1])==ARGV[1] "
             + "then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) "
             + "else return nil end";
Then call it here instead of the GET+SET pair.
✅ 5 resolved
✅ Edge Case: Checkpoint written before offset is advanced — crash loses page

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java:295-309
At line 300, writeCheckpoint(entityType, offset + page.size()) is called inside the try block, before offset += page.size() at line 309. If the process crashes between line 300 and 309 (or if bundleBatcher.warmupBatch throws a checked exception that isn't caught here), the checkpoint already advanced past the page. On resume, that page would be skipped. This is actually the intended behavior (don't re-warm already-cached pages), but note that the page's Redis pipeline write succeeded while the bundle warmup may have failed — so bundles for that page are lost silently. Consider writing the checkpoint only after both the entity and bundle writes succeed, or logging the discrepancy.

✅ Bug: releaseClaim deletes another instance's lock (no owner check)

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java:342-351
The distributed claim pattern has a classic unsafe-unlock race: instance A claims entity type T (SETNX with 10-min TTL). If A takes longer than 10 minutes, the key expires and instance B successfully claims T. When A eventually finishes, releaseClaim blindly calls cacheProvider.del(CLAIM_KEY_PREFIX + entityType) — deleting B's active claim. A third instance C could then also start warming T, defeating the distributed-claim guarantee.

The fix is to use a compare-and-delete: read the current value, and only delete if it matches this instance's instanceId. Ideally this should be an atomic Lua script or a Redis GET + conditional DEL.

✅ Performance: SCAN-based scanCount is O(n) over entire keyspace

📄 openmetadata-service/src/main/java/org/openmetadata/service/cache/RedisCacheProvider.java:434-448
RedisCacheProvider.scanCount iterates the full keyspace with SCAN to count matching keys. For large Redis instances with millions of keys this is expensive and blocks the calling thread for an extended period. The .limit(1000) hint is advisory — Redis may return more or fewer keys per iteration — and total wall time scales linearly with keyspace size.

Consider maintaining an approximate count via a separate counter key (incremented on write, decremented on delete) or using DBSIZE with a sampling approach, rather than scanning the whole keyspace at report time.

✅ Edge Case: readAppConfigFlags silently ignores string-typed booleans

📄 openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java:193-200
The readAppConfigFlags method checks wb instanceof Boolean and dc instanceof Boolean, but depending on how the app configuration is serialized/deserialized (e.g., from YAML env-var overrides or API string inputs), these values may arrive as "true"/"false" strings rather than native Boolean objects. In that case the flags are silently ignored and fall back to System properties, which could surprise operators who set the flags in the app config UI.

Other native apps avoid this by using JsonUtils.convertValue to deserialize directly into a typed POJO. Since these two fields aren't part of EventPublisherJob, consider parsing the value with Boolean.parseBoolean(String.valueOf(wb)) to handle both types robustly.

✅ Edge Case: Tag invalidation misses recently-tagged entities not in search

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:2984-2998
invalidateCacheForTaggedEntities relies on the search index to find entities tagged with a given FQN. The Javadoc acknowledges this: "Recently-tagged entities not yet in search are missed; they fall back to the entity TTL." This is an inherent limitation of the approach, but worth noting that the staleness window depends on the search index replication lag, which can be minutes in busy clusters. If strict consistency is required in the future, a direct tag_usage table query would be more reliable (at the cost of a DB round-trip).

🤖 Prompt for agents
Code Review: Implements Redis-backed cache invalidation for tag renames and relationship updates while adding a robust, checkpoint-aware bundle warmup mechanism. Address the TOCTOU race condition in `refreshClaim` by using an atomic operation to prevent concurrent owner conflicts.

1. 💡 Edge Case: refreshClaim has TOCTOU race between GET and SET
   Files: openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/cache/CacheWarmupApp.java:423-437

   The `refreshClaim` method reads the current owner via `GET`, then conditionally writes back with `SET` — these two calls are not atomic. Between the GET and SET another instance could acquire the claim (if the TTL just expired), and the SET would silently overwrite the new owner's lock.
   
   The Javadoc acknowledges the non-atomicity and argues the consequence is only redundant work (Redis writes are idempotent). This is a fair assessment — the claim is an optimization, not a correctness lock — so the impact is limited to occasional duplicate warmup work rather than data corruption. Still, a Lua script (`if redis.call('get',KEYS[1])==ARGV[1] then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) end`) would close the window cleanly, similar to the well-known Redlock refresh pattern.

   Suggested fix:
   Add a compareAndSet (or setIfEquals) method to CacheProvider
   backed by a Lua script:
     String lua = "if redis.call('get',KEYS[1])==ARGV[1] "
                + "then return redis.call('set',KEYS[1],ARGV[1],'PX',ARGV[2]) "
                + "else return nil end";
   Then call it here instead of the GET+SET pair.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 62%
62.42% (62854/100681) 42.71% (33824/79184) 45.72% (10016/21903)

@sonarqubecloud

sonarqubecloud Bot commented May 2, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented May 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (12 flaky)

✅ 3985 passed · ❌ 0 failed · 🟡 12 flaky · ⏭️ 86 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 298 0 1 4
🟡 Shard 2 749 0 5 8
🟡 Shard 3 745 0 2 7
✅ Shard 4 775 0 0 18
✅ Shard 5 687 0 0 41
🟡 Shard 6 731 0 4 8
🟡 12 flaky test(s) (passed on retry)
  • Pages/AuditLogs.spec.ts › should apply both User and EntityType filters simultaneously (shard 1, 1 retry)
  • Features/ActivityAPI.spec.ts › Activity event is created when description is updated (shard 2, 1 retry)
  • Features/ActivityAPI.spec.ts › Activity event shows the actor who made the change (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should display correct status badge color and icon (shard 2, 1 retry)
  • Features/Glossary/LargeGlossaryPerformance.spec.ts › should search and filter glossary terms (shard 2, 1 retry)
  • Features/IncidentManager.spec.ts › Verify filters in Incident Manager's page (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Flow/IngestionBot.spec.ts › Ingestion bot should be able to access domain specific domain (shard 3, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)
  • Pages/ServiceEntity.spec.ts › Announcement create, edit & delete (shard 6, 1 retry)
  • Pages/UserDetails.spec.ts › Create team with domain and verify visibility of inherited domain in user profile after team removal (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@harshach
harshach merged commit 620d1b6 into main May 2, 2026
68 of 70 checks passed
@harshach
harshach deleted the harshach/cache-fixes-warmup branch May 2, 2026 21:50
jatinmasaram pushed a commit to jatinmasaram/OpenMetadata that referenced this pull request May 3, 2026
…mup (open-metadata#27864)

* Cache audit fixes: tag rename invalidation, relationship invalidation, bundle warmup

Fix two write-through cache correctness bugs and enhance the warmup app:

Bug A — Tag/Glossary/Classification rename now invalidates the cached entity
JSON for every entity tagged with the renamed tag. Adds
invalidateCacheForTaggedEntities helpers in EntityRepository that use the
search index (same source updateClassificationTagByFqnPrefix already uses) to
enumerate affected entities, then call invalidateCacheForEntity for each.
Wired into TagRepository, ClassificationRepository, and both rename + parent-
move paths in GlossaryTermRepository.

Bug B — Direct addRelationship/deleteRelationship and bulk variants now
invalidate the cached bundle/owners/domains on both sides. Bot/Domain/Data
Product (already in UNCACHED_ENTITY_TYPES) short-circuit in
invalidateCacheForEntity so cascade-heavy delete paths don't pay for Redis
ops on keys that were never written.

Warmup enhancements — new BundleWarmupBatcher pre-warms the per-entity bundle
cache (tags + certification) using batched tag_usage queries; relations stay
lazy. CacheWarmupApp adds per-entity-type checkpoint resume, opt-in
SETNX-based distributed claim for multi-instance deploys, and per-entity-type
cache.warmup.coverage / cache.warmup.bundle.coverage gauges. CacheProvider
gains scanCount; CacheMetrics gains coverage gauges and a completed_runs
counter. cacheWarmupAppConfig.json drops dead consumerThreads/queueSize and
adds warmBundles + enableDistributedClaim flags.

Tests — BundleWarmupBatcherTest covers the batcher with mocked DAO/cache.
TagRenameCacheIT and RelationshipCacheInvalidationIT cover the bug fixes
end-to-end under the cache-tests / postgres-os-redis profile.


* Update generated TypeScript types

* Address PR review: claim ownership, config wiring, coverage, keyspace

Six follow-ups against PR open-metadata#27864:

- releaseClaim now does a compare-and-delete: GET the owner first and only
  DEL when it matches our instanceId. Previously a 10-min TTL could expire
  mid-warm, another instance could claim, and we'd blindly delete its lock.
- warmBundles / enableDistributedClaim are now read from the user-supplied
  app config map (matching the cacheWarmupAppConfig.json schema fields)
  instead of being JVM-system-property-only. System properties remain a
  fallback for bootstrap / unedited records.
- Per-entity-type checkpoint and claim keys now embed cacheConfig.redis
  .keyspace so two environments sharing one Redis with different keyspaces
  no longer collide on warmup metadata.
- reportCoverage now prefers scanCount over current-run success delta when
  available, so resumed runs report end-state coverage instead of the
  artificially low partial number.
- CacheWarmupApp class Javadoc updated to reflect that bundle pre-warm is
  on by default; intentionally-not-done text was stale.
- RelationshipCacheInvalidationIT Javadoc clarifies that the assertion is
  on the cacheable table side; Domain itself is in UNCACHED_ENTITY_TYPES.
- CacheProvider.scanCount Javadoc documents the O(DBSIZE) cost so callers
  don't drop it on the request path.
- EntityRepository.invalidateCacheForTaggedEntities Javadoc strengthens
  the search-lag tradeoff section with the actual fallback (entity TTL).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* PR review: accept string and Boolean forms for warmup config flags

readAppConfigFlags previously only accepted Boolean.TRUE / Boolean.FALSE.
Depending on how the app config arrives (typed POJO, raw JSON, YAML
env-var override, API string body) the same logical value can land as a
"true"/"false" string — and the instanceof Boolean check would silently
ignore it and fall back to the JVM system property. Operators setting the
flag in the UI would see no effect. Added a small parseBooleanFlag helper
that handles both shapes.
jaya6400 pushed a commit to jaya6400/OpenMetadata that referenced this pull request May 4, 2026
…mup (open-metadata#27864)

* Cache audit fixes: tag rename invalidation, relationship invalidation, bundle warmup

Fix two write-through cache correctness bugs and enhance the warmup app:

Bug A — Tag/Glossary/Classification rename now invalidates the cached entity
JSON for every entity tagged with the renamed tag. Adds
invalidateCacheForTaggedEntities helpers in EntityRepository that use the
search index (same source updateClassificationTagByFqnPrefix already uses) to
enumerate affected entities, then call invalidateCacheForEntity for each.
Wired into TagRepository, ClassificationRepository, and both rename + parent-
move paths in GlossaryTermRepository.

Bug B — Direct addRelationship/deleteRelationship and bulk variants now
invalidate the cached bundle/owners/domains on both sides. Bot/Domain/Data
Product (already in UNCACHED_ENTITY_TYPES) short-circuit in
invalidateCacheForEntity so cascade-heavy delete paths don't pay for Redis
ops on keys that were never written.

Warmup enhancements — new BundleWarmupBatcher pre-warms the per-entity bundle
cache (tags + certification) using batched tag_usage queries; relations stay
lazy. CacheWarmupApp adds per-entity-type checkpoint resume, opt-in
SETNX-based distributed claim for multi-instance deploys, and per-entity-type
cache.warmup.coverage / cache.warmup.bundle.coverage gauges. CacheProvider
gains scanCount; CacheMetrics gains coverage gauges and a completed_runs
counter. cacheWarmupAppConfig.json drops dead consumerThreads/queueSize and
adds warmBundles + enableDistributedClaim flags.

Tests — BundleWarmupBatcherTest covers the batcher with mocked DAO/cache.
TagRenameCacheIT and RelationshipCacheInvalidationIT cover the bug fixes
end-to-end under the cache-tests / postgres-os-redis profile.


* Update generated TypeScript types

* Address PR review: claim ownership, config wiring, coverage, keyspace

Six follow-ups against PR open-metadata#27864:

- releaseClaim now does a compare-and-delete: GET the owner first and only
  DEL when it matches our instanceId. Previously a 10-min TTL could expire
  mid-warm, another instance could claim, and we'd blindly delete its lock.
- warmBundles / enableDistributedClaim are now read from the user-supplied
  app config map (matching the cacheWarmupAppConfig.json schema fields)
  instead of being JVM-system-property-only. System properties remain a
  fallback for bootstrap / unedited records.
- Per-entity-type checkpoint and claim keys now embed cacheConfig.redis
  .keyspace so two environments sharing one Redis with different keyspaces
  no longer collide on warmup metadata.
- reportCoverage now prefers scanCount over current-run success delta when
  available, so resumed runs report end-state coverage instead of the
  artificially low partial number.
- CacheWarmupApp class Javadoc updated to reflect that bundle pre-warm is
  on by default; intentionally-not-done text was stale.
- RelationshipCacheInvalidationIT Javadoc clarifies that the assertion is
  on the cacheable table side; Domain itself is in UNCACHED_ENTITY_TYPES.
- CacheProvider.scanCount Javadoc documents the O(DBSIZE) cost so callers
  don't drop it on the request path.
- EntityRepository.invalidateCacheForTaggedEntities Javadoc strengthens
  the search-lag tradeoff section with the actual fallback (entity TTL).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* PR review: accept string and Boolean forms for warmup config flags

readAppConfigFlags previously only accepted Boolean.TRUE / Boolean.FALSE.
Depending on how the app config arrives (typed POJO, raw JSON, YAML
env-var override, API string body) the same logical value can land as a
"true"/"false" string — and the instanceof Boolean check would silently
ignore it and fall back to the JVM system property. Operators setting the
flag in the UI would see no effect. Added a small parseBooleanFlag helper
that handles both shapes.
harshach added a commit that referenced this pull request May 4, 2026
…mup (#27864)

* Cache audit fixes: tag rename invalidation, relationship invalidation, bundle warmup

Fix two write-through cache correctness bugs and enhance the warmup app:

Bug A — Tag/Glossary/Classification rename now invalidates the cached entity
JSON for every entity tagged with the renamed tag. Adds
invalidateCacheForTaggedEntities helpers in EntityRepository that use the
search index (same source updateClassificationTagByFqnPrefix already uses) to
enumerate affected entities, then call invalidateCacheForEntity for each.
Wired into TagRepository, ClassificationRepository, and both rename + parent-
move paths in GlossaryTermRepository.

Bug B — Direct addRelationship/deleteRelationship and bulk variants now
invalidate the cached bundle/owners/domains on both sides. Bot/Domain/Data
Product (already in UNCACHED_ENTITY_TYPES) short-circuit in
invalidateCacheForEntity so cascade-heavy delete paths don't pay for Redis
ops on keys that were never written.

Warmup enhancements — new BundleWarmupBatcher pre-warms the per-entity bundle
cache (tags + certification) using batched tag_usage queries; relations stay
lazy. CacheWarmupApp adds per-entity-type checkpoint resume, opt-in
SETNX-based distributed claim for multi-instance deploys, and per-entity-type
cache.warmup.coverage / cache.warmup.bundle.coverage gauges. CacheProvider
gains scanCount; CacheMetrics gains coverage gauges and a completed_runs
counter. cacheWarmupAppConfig.json drops dead consumerThreads/queueSize and
adds warmBundles + enableDistributedClaim flags.

Tests — BundleWarmupBatcherTest covers the batcher with mocked DAO/cache.
TagRenameCacheIT and RelationshipCacheInvalidationIT cover the bug fixes
end-to-end under the cache-tests / postgres-os-redis profile.


* Update generated TypeScript types

* Address PR review: claim ownership, config wiring, coverage, keyspace

Six follow-ups against PR #27864:

- releaseClaim now does a compare-and-delete: GET the owner first and only
  DEL when it matches our instanceId. Previously a 10-min TTL could expire
  mid-warm, another instance could claim, and we'd blindly delete its lock.
- warmBundles / enableDistributedClaim are now read from the user-supplied
  app config map (matching the cacheWarmupAppConfig.json schema fields)
  instead of being JVM-system-property-only. System properties remain a
  fallback for bootstrap / unedited records.
- Per-entity-type checkpoint and claim keys now embed cacheConfig.redis
  .keyspace so two environments sharing one Redis with different keyspaces
  no longer collide on warmup metadata.
- reportCoverage now prefers scanCount over current-run success delta when
  available, so resumed runs report end-state coverage instead of the
  artificially low partial number.
- CacheWarmupApp class Javadoc updated to reflect that bundle pre-warm is
  on by default; intentionally-not-done text was stale.
- RelationshipCacheInvalidationIT Javadoc clarifies that the assertion is
  on the cacheable table side; Domain itself is in UNCACHED_ENTITY_TYPES.
- CacheProvider.scanCount Javadoc documents the O(DBSIZE) cost so callers
  don't drop it on the request path.
- EntityRepository.invalidateCacheForTaggedEntities Javadoc strengthens
  the search-lag tradeoff section with the actual fallback (entity TTL).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* PR review: accept string and Boolean forms for warmup config flags

readAppConfigFlags previously only accepted Boolean.TRUE / Boolean.FALSE.
Depending on how the app config arrives (typed POJO, raw JSON, YAML
env-var override, API string body) the same logical value can land as a
"true"/"false" string — and the instanceof Boolean check would silently
ignore it and fall back to the JVM system property. Operators setting the
flag in the UI would see no effect. Added a small parseBooleanFlag helper
that handles both shapes.

This branch was previously deployed

1 inactive deployment
test — 51fb97c2 Deployed May 2, 2026 by harshach via playwright-ci-postgresql (5, 6) #45210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants