Claude Opus 5.5 · Heavy

span-buffer-multiprocess-enhancement-with-health-monitoring-sentry

Sentry · Python · M · 100–299 lines · 4 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
2 of 2
Comments published
5
Comments matching a bug
2
Comments not matching
3
Cost of this PR
$2.324

Published comments (5)

mediumperformancesrc/sentry/spans/consumers/process/flusher.py:299-301

Redis memory info queried once per flusher buffer on every submit — All buffers share one Redis cluster client, so each `get_memory_info()` call hits every node and N buffers send N times the INFO calls for identical data. Call `get_memory_info()` once on a single buffer instead of per entry in `self.buffers`.

mediumbugtests/sentry/spans/consumers/process/test_consumer.py:60-64

Patched no-op `time.sleep` makes the flusher wait in test_basic racy — `time.sleep` is patched to a no-op, so `step.join()` sets `stopped` immediately and whether `messages` fills depends on thread scheduling. Poll until `messages` is non-empty or a deadline passes using an unpatched wait, then call `join()`.

mediumbugsrc/sentry/spans/consumers/process/flusher.py:253-259

Hung spawn flusher process is never killed before restart — `isinstance(process, multiprocessing.Process)` is False for spawn-context processes, so the old process keeps flushing the same shards alongside its replacement, racing on Redis and leaving orphans. Check against `multiprocessing.process.BaseProcess` so `kill()` actually runs.

mediumbugsrc/sentry/spans/consumers/process/flusher.py:337-347

Flusher processes not terminated after join deadline passes — The `break` skips `terminate()` for the current process and all later ones, leaving them running. Skip only the wait when time is up and still call `terminate()` on every process.

mediumbugsrc/sentry/spans/consumers/process/flusher.py:199

wait_produce metric tagged "shards" instead of "shard" like other metrics — Dashboards filtering or grouping by `shard` will silently miss `spans.buffer.flusher.wait_produce`, since `produce`, `segment_size_bytes` and `flusher_unhealthy` all use `"shard"`. Rename the tag key to `"shard"`.

Gold bugs found (2)

highThe restart path only kills a hung flusher if it is a multiprocessing.Process, but spawn-context workers are SpawnProcess, so hung processes are never killed and a duplicate flusher is started for the same shards.
mediumjoin() breaks out of the per-process loop when the shared deadline expires, skipping termination of the remaining flusher processes and leaving them running after shutdown.

Gold bugs missed (0)

None.