fix(replays): use keyset pagination in delete_replays finder so it stops timing out Snuba - #121027
Open
strongs wants to merge 1 commit into
Open
fix(replays): use keyset pagination in delete_replays finder so it stops timing out Snuba#121027strongs wants to merge 1 commit into
strongs wants to merge 1 commit into
Conversation
ryan953
approved these changes
Jul 31, 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.
Problem: the
delete_replaysGoCD custom job (getsentry.jobs.delete_replays.DeleteReplays, running since 2026-07-23 to clear Ramp's iOS/Android replays for a PII leak) times out Snuba reads and crashes. Symptom is SENTRY-5S8N:SnubaError: HTTPConnectionPool(host='snuba-api', port=80): Read timed out. (read timeout=30), referrerreplays.scripts.delete_replays.Root cause is deep-offset pagination in the finder.
delete_replayspages with a growingOFFSET:_get_rows_matching_deletion_patternruns aGROUP BY replay_idaggregation over the whole project + time window withset_limit(batch_size)/set_offset(offset).OFFSETis not a cheap seek in ClickHouse. To return the rows at a given offset, it has to scan and aggregate every earlier row and then throw them away.sentry/utils/snuba.py, the query is abandoned, and the job crashes. The notebook saw the same wall: "dry run failed before 1:34 @ offset 871,000."There's a second, latent defect in the same query: it has no
ORDER BYat all. Offset paging over an unordered result is non-deterministic, so ClickHouse can reorder rows between pages and the job can silently skip or double-process replays.Fix: switch the finder to keyset (seek) pagination on
replay_id.