Skip to content

feat(replacer): optional concurrent replacement processing - #8376

Closed
sentry-junior[bot] wants to merge 1 commit into
masterfrom
feat/replacer-concurrent-processing
Closed

feat(replacer): optional concurrent replacement processing#8376
sentry-junior[bot] wants to merge 1 commit into
masterfrom
feat/replacer-concurrent-processing

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Spike / discussion PR: show what multi-message replacement concurrency could look like on one errors-replacer consumer.

Why

Today the errors replacer processes one kafka message at a time (RunTaskflush_batch([one])). Intra-message work already fans out across clickhouse shards, but independent replacements (especially different projects) cannot overlap.

During the US replacements backlog discussion we asked whether we could process more than one replacement at once without adding replicas. This PR sketches that path.

What changed

  • New CLI flag: --concurrency (default 1, current behavior).
  • concurrency > 1 switches the strategy to arroyo RunTaskInThreads.
  • Same-project_id replacements stay serial via per-project locks.
  • Shared worker state (offset map, project time counter, connection refresh, schema init, optimize) is locked for thread safety.
  • Factory/CLI unit coverage for the strategy choice.

What this does not do

  • Does not help a single hot project/group on one partition much — that work is still one-at-a-time by design.
  • Cross-project messages on the same partition may complete out of kafka order when concurrency > 1. That is an intentional spike tradeoff and needs a real correctness review before any prod enablement.
  • No deploy/ops wiring; default stays 1.

How to try

snuba replacer --storage errors --concurrency 4 ...

Test plan

  • tests/cli/test_replacer.py expects concurrency passthrough
  • factory tests for RunTask vs RunTaskInThreads and invalid concurrency
  • full replacer integration suite in CI
  • if ever considered for prod: load-test mixed-project backlog and same-project ordering guarantees

Requested by PDPM.

--

View Junior Session in Sentry

Add a --concurrency flag so one errors-replacer consumer can run more than
one replacement message at a time via RunTaskInThreads. Same-project work
stays serial; default concurrency=1 preserves the current path.

Co-Authored-By: PDPM <pierre.massat@sentry.io>
@sentry-junior
sentry-junior Bot requested a review from phacops August 21, 2026 23:24
@phacops phacops closed this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant