fix(workflow_engine): Reduce DataCondition cache TTL - #122422
Open
kcons wants to merge 1 commit into
Open
Conversation
kcons
marked this pull request as ready for review
August 21, 2026 22:28
Comment on lines
89
to
90
| function behavior and a batch method for efficient bulk operations. | ||
| """ |
Contributor
There was a problem hiding this comment.
Bug: The caching logic in CachedFunction.__call__ incorrectly treats a cached None value as a cache miss, causing the decorated function to be re-executed unnecessarily.
Severity: MEDIUM
Suggested Fix
Use a sentinel object to distinguish a cache miss from a stored None value. Initialize a unique object, e.g., _sentinel = object(), and use it as the default for cache.get. The subsequent check should be against this sentinel object, not None.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/utils/function_cache.py#L89-L90
Potential issue: The caching mechanism in `CachedFunction.__call__` uses `cache.get(key,
None)` and then checks `if result is None` to determine if there was a cache miss. This
logic is flawed because it cannot distinguish between a cache miss and a case where the
value `None` was legitimately cached. As a result, any cached function that returns
`None` (such as `_load_service_hook`) will have its result recomputed on every call
instead of being retrieved from the cache, defeating the purpose of caching for these
specific return values.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
7d is much longer than we need, and means bad cache issues need manual intervention.
4h should be basically just as good for performance purposes, and seems more reasonable.
While here, make the TTL required in the API we're using so it's clear where things are cached for long durations.