fix(spans): Enable better_backpressure in span buffer RunTask#113692
Merged
fix(spans): Enable better_backpressure in span buffer RunTask#113692
Conversation
| ), | ||
| next_step=flusher, | ||
| better_backpressure=True, | ||
| ) |
Contributor
There was a problem hiding this comment.
Bug: The better_backpressure=True parameter is missing in a fallback path used only in contrived test scenarios where multiprocessing is disabled but multiple processes are requested.
Severity: LOW
Suggested Fix
In src/sentry/utils/arroyo.py, update the run_task_with_multiprocessing function to pass better_backpressure=True to the RunTask constructor within the fallback logic. This will ensure consistent behavior across all code paths, even those not used in production.
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/spans/consumers/process/factory.py#L125
Potential issue: In a specific, non-production scenario, the `better_backpressure=True`
parameter is not applied to the stream processor. This occurs when the
`KAFKA_CONSUMER_FORCE_DISABLE_MULTIPROCESSING` setting is enabled (typically only for
tests) while simultaneously requesting more than one process (`num_processes > 1`). The
primary production path, which uses a single process, correctly receives the
`better_backpressure=True` parameter. The fallback path, handled by
`run_task_with_multiprocessing()` in `src/sentry/utils/arroyo.py`, was not updated to
include this parameter, leading to the inconsistency. However, this combination of
settings is not used in production or existing tests.
Also affects:
src/sentry/utils/arroyo.py
Did we get this right? 👍 / 👎 to inform future reviews.
Member
Author
There was a problem hiding this comment.
it's legitimate but not worth fixing. i just want to see this rolled out in prod
lvthanh03
approved these changes
Apr 22, 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.
Bumps arroyo to 2.39.0 and enables the new
better_backpressure=Trueflag in the span buffer's RunTask.When the flusher applies backpressure, the current RunTask implementation re-raises
MessageRejectedand re-runs the user function on each retry attempt. This causes increased CPU load on Redis becauseadd-buffer.luaexecutes multiple times per message.With
better_backpressure=True, the function runs exactly once per message — transformed messages are stored on backpressure and retried inpoll()instead.See getsentry/arroyo#536 for the arroyo change.
Ref STREAM-881