Repository navigation
[feat] PIP-468: V5 StreamConsumer disconnect / reconnect / past-grace reassignment - #25619
Merged
Merged
Conversation
…reassignment Two new tests for V5 StreamConsumer multi-consumer dynamics: - testStreamConsumerReconnectWithinGraceKeepsAssignment: alice + bob share a 4-segment topic. Force-disconnect alice (close her dedicated client), reconnect with the same consumerName well within the controller grace period, send a second batch with the same key set. Each consumer's per-key share must be identical across batches — proving the controller re-attached alice's existing session without rebalancing. - testStreamConsumerDisconnectPastGraceTriggersReassignment: same setup, but alice stays away past the grace period. After the timer fires the controller evicts her session and rebalances; bob ends up serving every key in the second batch. Wiring: - ServiceConfiguration grows scalableTopicConsumerSessionGracePeriodSeconds (default 60s, matching the previous hard-coded value). - ScalableTopicController.createCoordinator passes the config value to the SubscriptionCoordinator instead of using the static default. - SharedPulsarCluster sets it to 2s so reassignment-after-disconnect can be exercised in a few seconds rather than a minute.
- Import java.time.Duration in ScalableTopicController instead of fully-qualifying inline. - testStreamConsumerReconnectWithinGraceKeepsAssignment: drop the dedicated client + force-disconnect dance. Closing and re-subscribing alice's consumer on the shared client is enough to exercise the re-attach-existing-session path; the controller looks up the session by consumerName. - testStreamConsumerDisconnectPastGraceTriggersReassignment: drop the fixed Thread.sleep before producing. Produce immediately and drain bob until every second-batch message lands; the rebalance fires mid-drain once the grace timer expires. Cap the drain with a generous deadline so a regression fails fast instead of hanging.
…tConfig() is null ScalableTopicServiceTest.testRegisterConsumerDelegates uses a Mockito-mocked PulsarService whose getConfig() returns null. The grace-period config lookup in createCoordinator NPE'd on it. Skip the config read when getConfig() is null and use the SubscriptionCoordinator's default constructor (60s grace).
lhotari
approved these changes
Apr 30, 2026
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
Two new V5 StreamConsumer multi-consumer dynamics tests, plus a small broker config to make them fast.
Tests
testStreamConsumerReconnectWithinGraceKeepsAssignment— alice + bob share a 4-segment topic. Close alice's consumer and re-subscribe with the sameconsumerName. The controller re-attaches to the existing session by name (no rebalance, no churn on bob). Same key set across both batches confirms each consumer keeps its segments.testStreamConsumerDisconnectPastGraceTriggersReassignment— same setup, but alice's underlying connection is severed (close her dedicated client) and she stays away past the grace period. Bob ends up serving every key in the second batch. Drain runs concurrently with the rebalance — noThread.sleepbetween disconnect and produce.Wiring
ServiceConfiguration.scalableTopicConsumerSessionGracePeriodSeconds(default 60s, matching the previous hard-coded value).ScalableTopicController.createCoordinatorreads it and passes it toSubscriptionCoordinatorinstead of using the static default.SharedPulsarClustersets it to 2s so reassignment-after-disconnect can be exercised in seconds rather than a minute.Test plan
./gradlew :pulsar-broker:test --tests \"org.apache.pulsar.client.api.v5.V5MultipleConsumersTest\"— all 5 tests pass; new tests run in ~2.2s and ~3.3s.Matching PR
area/test