Repository navigation
Description
Detail Bug Report
Introduced in #24919 by @mohityadav766 on Dec 21, 2025
Summary
- Context:
GuavaLineageGraphCachecaches built lineage graphs server-side (enabled by default, 5-minute TTL) so repeated/v1/lineage/getLineagecalls skip expensive Elasticsearch traversal. - Bug:
LineageCacheKey.fromRequest()builds the cache key from only a subset ofSearchLineageRequestfields — it omitslayerFrom,layerSize,includeDeletedandincludeSourceFields, even though the graph built byESLineageGraphBuilder/OSLineageGraphBuilderdepends on all four. - Actual vs. expected: Two requests differing only in these fields produce identical cache keys, so the second caller is served the first caller's cached graph (e.g. within
/getLineage, afrom=100&size=50request receives the graph built forfrom=0&size=1000;directionis keyed, so/getLineageand/getLineage/{direction}never collide with each other); expected behavior is a distinct cache entry per distinct request variant. - Impact: Users silently receive wrong lineage graphs — wrong pages of edges, or graphs containing (or missing) deleted entities — for up to the TTL after a variant that differs only in pagination or
includeDeletedwarms the cache.
Code with Bug
openmetadata-service/src/main/java/org/openmetadata/service/search/lineage/LineageCacheKey.java:
/**
* ...
* All fields that affect the lineage result must be included in the key. // <-- BUG 🔴 key omits request fields that affect results
*/
public static LineageCacheKey fromRequest(SearchLineageRequest request) {
...
return new LineageCacheKey(
request.getFqn() != null ? request.getFqn() : "",
request.getUpstreamDepth() != null ? request.getUpstreamDepth() : 0,
request.getDownstreamDepth() != null ? request.getDownstreamDepth() : 0,
request.getQueryFilter() != null ? request.getQueryFilter() : "",
request.getColumnFilter() != null ? request.getColumnFilter() : "",
request.getPreservePaths() != null ? request.getPreservePaths() : Boolean.TRUE,
request.getDirection() != null ? request.getDirection().value() : "",
request.getIsConnectedVia() != null ? request.getIsConnectedVia() : Boolean.FALSE,
0, // from <-- BUG 🔴 hardcoded, not request.getLayerFrom()
0, // size <-- BUG 🔴 hardcoded, not request.getLayerSize()
0,
Boolean.FALSE,
0,
0,
request.getStartTime(),
request.getendTime()); // <-- BUG 🔴 includeDeleted/includeSourceFields also not in key
}openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ESLineageGraphBuilder.java (mirrored in OSLineageGraphBuilder.java):
List<EsLineageData> paginatedUpstreamEntities =
paginateList(
upStreamEntities, lineageRequest.getLayerFrom(), lineageRequest.getLayerSize());
SearchRequest searchRequest =
EsUtils.getSearchRequest(
lineageRequest.getDirection(),
GLOBAL_SEARCH_ALIAS,
lineageRequest.getQueryFilter(),
GRAPH_AGGREGATION,
directionKeyAndValues,
lineageRequest.getLayerFrom(),
lineageRequest.getLayerSize(),
lineageRequest.getIncludeDeleted(), // <-- BUG 🔴 affects ES query but not cache key
...);Explanation
- The server-side cache uses
LineageCacheKey.fromRequest()to index cached lineage graphs. ESLineageGraphBuilder/OSLineageGraphBuilderbuild results usinglayerFrom/layerSize(pagination) andincludeDeleted(ES filtering);includeSourceFieldsaffects hydration.- Because these fields are not incorporated into the cache key, different request variants collide and the cache can return a graph built for a different
from/size/includeDeleted/includeSourceFieldscombination. - On a cache hit, the builder returns the cached result verbatim (
return cached.get();) with no post-cache pagination/normalization, so incorrect results are served for up to the TTL.
Codebase Inconsistency
LineageCacheKey’s javadoc explicitly states: “All fields that affect the lineage result must be included in the key.”- The UI-side lineage scene cache (
LineageSceneCache, documented indocs/perf/lineage-scale-validation.md) intentionally keys on parameters includingsizeandincludeDeleted, indicating the server-side omission is not an accepted design.
Recommended Fix
- Include
layerFrom,layerSize, andincludeDeletedinLineageCacheKeyand populate them from the request infromRequest()so distinct request variants get distinct cache entries. - Decide how to handle
includeSourceFields: either add it to the key or re-hydrate node payload post-cache if the cached graph is meant to be source-field-agnostic. - Update tests that currently assert
fromRequesthardcodes pagination fields (e.g.,testFromRequestDefaultsPaginationFields).
History
This bug was introduced in commit 9c80936 ("Lineage Improvements (#24919)", Mohit Yadav, Dec 2025). That PR introduced server-side lineage result caching (GuavaLineageGraphCache, AbstractLineageGraphBuilder.checkCache/cacheResult, enabled by default via LineageGraphConfiguration) along with LineageCacheKey.fromRequest() — and from day one the key contained only fqn, depths, queryFilter, columnFilter, preservePaths, direction and isConnectedVia, with no layerFrom/layerSize/includeDeleted/includeSourceFields fields at all, even though the surrounding code in the same commit (ESLineageGraphBuilder/OSLineageGraphBuilder) builds the cached graph from paginateList(..., getLayerFrom(), getLayerSize()) and ES queries filtered by getIncludeDeleted(), and serves cache hits verbatim.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity