fix: Trigger ad-hoc explorer index runs#116530
Open
shruthilayaj wants to merge 2 commits into
Open
Conversation
| # ensure there is some padding before the end of the duration | ||
| remaining -= step | ||
|
|
||
| return batch_index * int(step.total_seconds()) % int(remaining.total_seconds()) |
Contributor
There was a problem hiding this comment.
Bug: The compute_delay function can cause a ZeroDivisionError if called during a specific second of the hour, as the remaining time can become zero before the modulo operation.
Severity: MEDIUM
Suggested Fix
Add a guard in compute_delay to handle cases where remaining.total_seconds() is zero or negative. For example, ensure the divisor for the modulo operation is at least 1. Using max(1, int(remaining.total_seconds())) as the divisor would prevent the division by zero.
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/tasks/utils.py#L33
Potential issue: The `compute_delay` function calculates a delay based on the time
remaining until the next hour. If the function is executed at a specific second (e.g.,
59 minutes and 43 seconds into the hour), the calculated `remaining` time can become
zero. This leads to a `ZeroDivisionError` during the modulo operation `... %
int(remaining.total_seconds())`. This pull request exposes the function to a new ad-hoc
call path triggered by user actions, making this edge case more likely. While the
exception is caught, it causes the associated explorer index tasks to silently fail to
dispatch.
Also affects:
src/sentry/receivers/outbox/cell.py:293~297
Did we get this right? 👍 / 👎 to inform future reviews.
Contributor
Backend Test FailuresFailures on
|
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.
The
organizations:seer-run-mirror-exploreron SeerAgentClient.start_run meantwe weren't triggering the ad-hoc create explorer index tasks. This PR now calls the
index build tasks for explorer runs.
compute_delaywas causing a circular import - so just moved that to a utils file