Repository navigation
Description
Detail Bug Report
Introduced in #27864 by @harshach on May 2, 2026
Summary
- Context: The Redis bundle cache is pre-warmed per entity type by
CacheWarmupApp(shipped enabled, hourly) throughBundleWarmupBatcher, which batch-fetches each asset's tags and bakes them into the cached bundle withtagsLoaded=true. On a cache-miss GET,EntityRepository.fillReadBundleinstead computes tags viafetchAndPutTagsWithCertification→TagLabelUtil.populateTagLabel. - Bug: The warmer's tag query (
getTagsInternalByTargetHashes) LEFT JOINstag/glossary_term_entityonfqnHashwith nodeletedfilter, so it enriches tag labels from the stored JSON of soft-deleted tags/glossary terms, while the canonical read path fetches enrichment entities withInclude.NON_DELETEDand serves the same label unenriched. - Actual vs. expected: For the same
tag_usagerow, a warmed cache-hit GET serves the label with the deleted tag/term'sname/displayName/description/style, while a cache-miss GET of the same asset serves it without those fields — the served value oscillates with the warmup/TTL schedule instead of both paths agreeing. - Impact: After a user recursively soft-deletes a Glossary or Classification, assets still carrying those terms/tags flip between showing the deleted term's stale display name/style/description (cache hit) and a bare, unenriched label (cache miss) for up to the 48h bundle TTL; the hourly warmup keeps re-baking the enriched variant, so the inconsistency self-perpetuates.
Code with Bug
Warmer tag fetch (openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ClassificationTagDAOs.java, getTagsInternalByTargetHashes):
SELECT tu.source, tu.tagFQN, tu.labelType, tu.targetFQNHash, tu.state, tu.reason, tu.appliedAt, tu.appliedBy, tu.metadata,
CASE
WHEN tu.source = 1 THEN gterm.json
WHEN tu.source = 0 THEN ta.json
END as json
FROM tag_usage tu
LEFT JOIN glossary_term_entity gterm ON tu.source = 1 AND gterm.fqnHash = tu.tagFQNHash
LEFT JOIN tag ta ON tu.source = 0 AND ta.fqnHash = tu.tagFQNHash
WHERE tu.targetFQNHash IN (<targetFQNHashes>) -- <-- BUG 🔴 deleted entities not filtered from joinMapper enriches from joined JSON whenever present:
if (source == TagLabel.TagSource.CLASSIFICATION) {
Tag tag = JsonUtils.readValue(json, Tag.class);
label.setName(tag.getName());
...
} else if (source == TagLabel.TagSource.GLOSSARY) {
GlossaryTerm glossaryTerm = JsonUtils.readValue(json, GlossaryTerm.class);
label.setName(glossaryTerm.getName()); // <-- BUG 🔴 enriches from soft-deleted term JSON
...
}Warmer bakes enriched labels into bundle and marks them authoritative:
dto.tags = stripCertificationTags(
tagsByFqnHash.getOrDefault(entry.getKey(), Collections.emptyList()), certClassification);
dto.tagsLoaded = true; // <-- BUG 🔴 cache hit skips canonical tag fetch/re-filteringCanonical cache-miss enrichment excludes deleted tag/term entities:
public static List<Tag> getTags(List<String> tagFQNs) {
return Entity.getEntityByNames(Entity.TAG, tagFQNs, "", NON_DELETED);
}
public static List<GlossaryTerm> getGlossaryTerms(List<String> tagFQNs) {
return Entity.getEntityByNames(Entity.GLOSSARY_TERM, tagFQNs, "", NON_DELETED);
}Explanation
- Recursive soft-deletes of a Glossary/Classification soft-delete child term/tag rows but do not purge
tag_usagerows (bulk soft-delete path flipsdeleted=trueon entity JSON and never calls per-entitypostDelete, where tag usage cleanup normally happens). This leaves live assets withtag_usagerows pointing at soft-deleted tag/term entities. - On cache miss,
populateTagLabelenriches labels by fetching tags/terms withInclude.NON_DELETED; for soft-deleted entities it gets no enrichment object and returns an unenriched label. - On cache hit after warmup, the warmer’s SQL join returns the soft-deleted tag/term JSON (because the join lacks a
deleted=falsepredicate), the row mapper enriches label fields from that JSON, andBundleWarmupBatcherstores the enriched labels withtagsLoaded=true.fillReadBundlethen serves those labels verbatim, skipping the canonical DB fetch. - Because warmup runs hourly and bundle TTL is 48h, the “enriched from deleted JSON” variant keeps getting re-baked; the same asset’s GET response changes depending on cache warmth.
Codebase Inconsistency
The warmer is intended to mirror canonical tag enrichment, but the canonical path explicitly uses NON_DELETED for tag/term lookups (see TagLabelUtil.getTags/getGlossaryTerms), while the warmer path does not filter deleted rows in SQL.
Recommended Fix
Filter deleted entities out of the warmer join in getTagsInternalByTargetHashes (and also getTagsInternalByPrefix for consistency) so the joined JSON is null for soft-deleted tags/terms and the existing “orphan” behavior returns an unenriched label matching the cache-miss path:
LEFT JOIN glossary_term_entity gterm ON tu.source = 1 AND gterm.fqnHash = tu.tagFQNHash AND gterm.deleted = FALSE
LEFT JOIN tag ta ON tu.source = 0 AND ta.fqnHash = tu.tagFQNHash AND ta.deleted = FALSEHistory
This bug was introduced in commit 620d1b6 (PR #27864, 2026-05-02), which added bundle pre-warming and started baking the warmer’s enriched labels into bundles with tagsLoaded=true, making warmed cache-hit GETs diverge from the canonical cache-miss path.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity
Fixes open-metadata#36024: exclude soft-deleted tags/terms from bundl…
chore(release): merge main into 2.1 (#38229)