feat(consumer): Add commit log heartbeat for idle partitions#7819
Draft
feat(consumer): Add commit log heartbeat for idle partitions#7819
Conversation
When the events topic has low per-partition throughput, some partitions may have no messages in a given batch window. Since Snuba only produces commit log entries for partitions with data, idle partitions get no entry. This causes the post-process-forwarder (SynchronizedConsumer) to pause those partitions and wait, increasing end-to-end latency with random spikes. On each batch flush, now produce commit log entries for ALL assigned partitions. For idle partitions, re-emit the last known committed offset as a heartbeat. This caps the maximum stall to one batch window (~500ms) instead of being unbounded. Changes: - Python: Add CommitLogHeartbeatState shared across batch writers - Python: ProcessedMessageBatchWriter and MultistorageCollector emit heartbeats for idle partitions in close() - Python: Wire heartbeat state through strategy factory and consumer builder - Rust: ProduceMessage tracks assigned partitions and last offsets, emits heartbeats for idle partitions - Tests: 8 new Python tests + 1 Rust test for heartbeat behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
SynchronizedConsumer) gates on the commit log — idle partitions get no entry, causing it to pause and wait, producing latency spikesChanges
CommitLogHeartbeatStateshared across batch writer instances, heartbeat logic inProcessedMessageBatchWriter.close()andMultistorageCollector.close()ProduceMessagetracks assigned partitions and last offsets, emits heartbeats for idle partitionsConsumerBuilder→build_batch_writer()+KafkaConsumerStrategyFactory, updated on each rebalance viacreate_with_partitions()Test plan
snuba-post-processorlatency spikes are reduced🤖 Generated with Claude Code