ref(track_outcome): use FutureTrackingProducer for everything#119126
Open
bmckerry wants to merge 1 commit into
Open
ref(track_outcome): use FutureTrackingProducer for everything#119126bmckerry wants to merge 1 commit into
bmckerry wants to merge 1 commit into
Conversation
Comment on lines
+176
to
183
| outcomes_producer = FutureTrackingProducer( | ||
| "sentry.utils.outcomes", | ||
| _get_outcomes_producer, | ||
| ) | ||
| billing_producer = SingletonProducer(_get_billing_producer) | ||
| billing_tp_name = "sentry.utils.outcomes.billing.taskproducer" | ||
| billing_task_producer = get_task_producer( | ||
| billing_tp_name, partial(_get_billing_producer, billing_tp_name) | ||
| billing_producer = FutureTrackingProducer( | ||
| "sentry.utils.outcomes.billing", | ||
| _get_billing_producer, | ||
| ) |
Contributor
There was a problem hiding this comment.
Bug: Replacing SingletonProducer with FutureTrackingProducer may cause outcome loss during server shutdown, as the new producer might close before OutcomeAggregator flushes its buffer.
Severity: HIGH
Suggested Fix
Verify that FutureTrackingProducer registers its atexit handler at construction time, ensuring it closes after OutcomeAggregator flushes during shutdown. Consider adding a test to confirm this shutdown ordering and prevent data loss.
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/outcomes.py#L176-L183
Potential issue: The replacement of `SingletonProducer` with `FutureTrackingProducer`
may reintroduce a shutdown-ordering bug. The previous implementation used an eager
`atexit` handler to ensure the producer remained active until after `OutcomeAggregator`
flushed its buffered outcomes during server shutdown. It is unclear if
`FutureTrackingProducer` provides the same guarantee. If the new producer's shutdown
handler runs before `OutcomeAggregator._atexit_flush()`, any outcomes flushed by the
aggregator during shutdown will be silently lost because the producer will already be
closed.
Did we get this right? 👍 / 👎 to inform future reviews.
Member
Author
There was a problem hiding this comment.
FutureTrackingProducer has effectively the same behaviour as SingletonProducer on shutdown
evanh
approved these changes
Jul 7, 2026
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.
getsentry/arroyo#547 introduced a producer abstraction in Arroyo which is essentially the same as
TaskProducerbut can be used anywhere, not just in tasks.This PR replaces
TaskProducerwithFutureTrackingProducerin track_outcome, and cleans up all of the rollout logic now that this is fully rolled out everywhere.