Conversation
Signed-off-by: Dream95 <zhou_8621@163.com>
Signed-off-by: Dream95 <zhou_8621@163.com>
lhotari
left a comment
There was a problem hiding this comment.
Thanks for reducing the consumer churn in this test. The new probe still has an input for which takeover is impossible, so the test is not yet deterministic. Please fix the initial consumer name and bound the search.
| String name = "takeover-" + i; | ||
| if (!existingNames.add(name)) { | ||
| continue; | ||
| } |
There was a problem hiding this comment.
[INTENT MISMATCH] Choose a suitable initial name and bound the takeover search
The initial consumer still gets a random five-character name. With the valid name 00807, the modern selector's replica point 78 (00807 + NUL + 0 + NUL + 78) and testMessageKey both hash to slot 21672 with the default 100 points and range 1..65535. The existing ring point always wins: putIfAbsent retains its owner, and select uses ceilingEntry. No takeover-N can therefore succeed. This loop never terminates, and existingNames keeps every attempted name.
The collision also affected the old loop, but moving the search into a probe does not resolve this case of the flaky test. Please give the initial consumer a fixed suitable name (or choose a compatible pair), bound the search, and cover the exact-point case.
Fixes #26568
Main Issue: #xyz
PIP: #xyz
Motivation
CI fails in
KeySharedSubscriptionTest.resetDefaultNamespacewith:Topic has 8005 clients connected Including 8004 consumers, 0 producers, and 0 replicators.
Example: https://github.com/apache/pulsar/actions/runs/34130276934/job/101987362625
The leftover clients come from
testMessageDeliveredFromDrainingHashes. That test usedaddConsumersUntilOwnerChanged, which kept creating Key_Shared consumers until consistent hashing movedtestMessageKeyoff the original owner.With
subscriptionKeySharedConsistentHashingReplicaPoints=100and a large hash space, a randomly named consumer often does not steal that hash. The loop can create thousands of consumers (8004 in the failure). The test then cannot finish cleanup before@AfterMethod, soresetDefaultNamespacecannot delete the topic.Modifications
Replace
addConsumersUntilOwnerChangedwithaddConsumerThatTakesOverHash. It picks a consumer name (takeover-N) that will own the target hash, subscribes that one consumer, and fails if the owner did not change.findConsumerNameThatTakesHashbuilds a localConsistentHashingStickyKeyConsumerSelectorwith the live replica-point count andselector.getKeyHashRange().getEnd().Cleanup only has that extra consumer to close.
findOwnerNameusesselector.select(hash).Verifying this change
This change is already covered by existing tests, such as
KeySharedSubscriptionTest.testMessageDeliveredFromDrainingHashes.Ran that method locally 500 times. All passed.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes