Skip to content

fix(workflow_engine): Reduce DataCondition cache TTL - #122422

Open
kcons wants to merge 1 commit into
masterfrom
kcons/lesscache
Open

fix(workflow_engine): Reduce DataCondition cache TTL#122422
kcons wants to merge 1 commit into
masterfrom
kcons/lesscache

Conversation

@kcons

@kcons kcons commented Aug 21, 2026

Copy link
Copy Markdown
Member

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.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 21, 2026
@kcons
kcons marked this pull request as ready for review August 21, 2026 22:28
@kcons
kcons requested review from a team as code owners August 21, 2026 22:28
Comment on lines 89 to 90
function behavior and a batch method for efficient bulk operations.
"""

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant