GLM-5.3 · 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
- 1 of 2
- Comments published
- 6
- Comments matching a bug
- 1
- Comments not matching
- 5
- Cost of this PR
- $2.165
Published comments (6)
Per-process SpansBuffer shards the max-flush-segments cap, multiplying it N× — Because each buffer budgets from its own shard subset, one process per shard means N× the `max-flush-segments` cap fetched from Redis and produced to Kafka each cycle, and the higher `any_shard_at_limit` threshold delays the `MessageRejected` backpressure in `submit()`. Have `SpansBuffer.flush_segments` compute the per-shard budget from the total shard count.
Redundant cluster-wide Redis INFO queries per buffer in submit() — Call `get_memory_info()` on any one buffer instead of iterating `self.buffers.values()`.
Shard distribution test passes even if all shards go to one process — The check is vacuous: `total_shards` only sums shard counts, and `process_to_shards_map` is pre-seeded with an entry per process index, so a regression in `process_index = i % self.num_processes` would go uncaught. Assert each process's shard list is non-empty (the expected 2/2 split).
wait_produce timer uses `shards` tag key instead of `shard` — Per-shard dashboards and alerts that aggregate by `shard` silently miss every `spans.buffer.flusher.wait_produce` sample, which splits the dimension into a second tag key unlike the sibling `spans.buffer.flusher.produce` and `spans.buffer.segment_size_bytes` timers. Use the `shard` key here.
max_processes=0 treated as unset; negative value crashes with KeyError — Use an `is not None` check and reject non-positive values. **Also found in:** - `src/sentry/spans/consumers/process/flusher.py:59-66` - `src/sentry/spans/consumers/process/flusher.py:60-66`
Expired join deadline skips terminate() for remaining flusher processes — On expiry the `break` skips `process.terminate()` for every remaining flusher, so a hung one never observes `stopped` and keeps producing on possibly reassigned shards; since segments are only removed via `done_flush_segments` after produce, racing flushers can emit duplicate span batches. Terminate each remaining process instead of breaking.