fix(tests): Fix flaky AI conversations tests exceeding Snuba retention#112612
Merged
mchen-sentry merged 2 commits intomasterfrom Apr 9, 2026
Merged
fix(tests): Fix flaky AI conversations tests exceeding Snuba retention#112612mchen-sentry merged 2 commits intomasterfrom
mchen-sentry merged 2 commits intomasterfrom
Conversation
…n window Tests used `before_now(days=90..109)` but `retention_days=90` is hardcoded in `span_to_trace_item()`. ClickHouse TTL merge can non-deterministically drop already-expired data, causing intermittent empty results. Move all timestamps to within the 90-day retention window and fix a duplicate `days=30` value.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 206953d. Configure here.
JoshFerge
approved these changes
Apr 9, 2026
george-sentry
pushed a commit
that referenced
this pull request
Apr 9, 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.

This flake has been showing frequently and being covered by retries.
The test stores spans into Snuba, then immediately queries them. Sometimes the query returns nothing:
assert len(response.data) == 1fails with 0.span_to_trace_item()hardcodesretention_days=90for all test spans. But these tests usebefore_now(days=107)and similar, so the span timestamps are already past their own retention period at insertion time.Original tests, days=10..80: ec760c4d8f4
Following tests added days 90..109:
Most likely the reason this flakes is that ClickHouse doesn't reject expired data on insert, and relies on a background process to clean up rows past their TTL. Assuming that the test is able to pass when the query runs before that process is able to clean these rows.
https://clickhouse.com/blog/using-ttl-to-manage-data-lifecycles-in-clickhouse

Fixed all 13 tests in this file that had
daysvalues >= 90 to within the retention window. Also fixed a duplicatedays=30between two tests.