Cover split partition queues with the periodic fallback wakeup#840
Open
davidak09 wants to merge 1 commit into
Open
Cover split partition queues with the periodic fallback wakeup#840davidak09 wants to merge 1 commit into
davidak09 wants to merge 1 commit into
Conversation
…keup split_partition_queue gave each partition its own WakerSlab but no periodic fallback wakeup. The main queue is woken every max.poll.interval.ms/2 to recover a lost edge-triggered non-empty wakeup; split queues were not, so a lost wakeup parked one partition's stream permanently while sibling partitions kept flowing. Spawn the same fallback per split queue; it holds a Weak and ends once the queue is dropped. Relates to fede1024#665.
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
StreamConsumer::split_partition_queuecan permanently stall a single partition's stream after a lost wakeup, while every other partition keeps consuming. This adds the periodic fallback wakeup to split partition queues that the main consumer queue already has.Background
A parked
MessageStreamis rewoken by an edge-triggered "queue non-empty" callback (native_message_queue_nonempty_cb) that only fires on an empty → non-empty transition. That edge can be missed (see #665), leaving the stream parked with no pending wakeup.The main consumer queue is protected against this:
from_config_and_contextspawns a background loop that callswakers.wake_all()everymax.poll.interval.ms / 2, so a missed edge self-heals within at most that interval.split_partition_queuecreates its ownWakerSlaband enables its own non-empty callback — but no equivalent fallback loop is spawned for it. So for split partition queues a missed wakeup is not recovered: the stream stays parked indefinitely.Impact
Consumers that use
split_partition_queue(one stream per partition for parallel/independent draining) can have a single partition silently stop consuming for hours/days while sibling partitions on the same consumer keep flowing. Only recreating the consumer clears it. This matches behavior reported downstream in vectordotdev/vector#22006 (one partition's lag climbs unbounded; the consumer is otherwise healthy, no errors logged).Fix
When
split_partition_queuecreates the queue'sWakerSlab, spawn the same fallback loop used for the main queue, waking that queue's wakers everymax.poll.interval.ms / 2. The loop holds aWeak<WakerSlab>and exits once the queue is dropped and itsWakerSlabis freed, so no shutdown plumbing or changes toStreamPartitionQueueare needed.poll_intervalis now stored onStreamConsumerto reuse the value parsed at construction.Net production change: one file, +10/−16.
Test
tests/test_partition_queue_wakeup.rs— a deterministic, broker-free regression test. It assigns and splits a partition, parks the stream by polling it with a custom waker (empty queue, no broker → no data), and asserts the stream is woken within the timeout. The only thing that can wake it is the fallback loop.Verified fail → pass: with the fallback loop removed the test times out (
never woken); with the fix it passes in ~0.5s.Validation
cargo test --lib— passes (no broker).split_partition_queuetests) — pass against a real broker (docker compose up+cargo test), no regression.Notes
Relates to #665; addresses the stuck-partition symptom in vectordotdev/vector#22006.
Developed with AI assistance and reviewed by me.