[Broker] Fix and improve topic ownership assignment - #13069
Merged
lhotari merged 14 commits intoDec 3, 2021
Conversation
lhotari
requested review from
addisonj,
codelipenghui,
eolivelli,
merlimat and
rdhabalia
December 1, 2021 13:49
eolivelli
reviewed
Dec 1, 2021
lhotari
force-pushed
the
lh-fix-topic-ownership-assignment
branch
from
December 1, 2021 17:41
534eec7 to
7c785d0
Compare
lhotari
force-pushed
the
lh-fix-topic-ownership-assignment
branch
from
December 2, 2021 19:00
7c785d0 to
e483775
Compare
lhotari
marked this pull request as ready for review
December 2, 2021 19:02
michaeljmarshall
approved these changes
Dec 2, 2021
eolivelli
reviewed
Dec 2, 2021
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
Member
Author
|
I fixed the test in https://github.com/lhotari/pulsar/commits/lh-fix-topic-ownership-assignment-branch-2.8 . I can now consistently reproduce the issue. It results in error 500 : |
Member
Author
|
Problem happens here: |
Member
Author
|
Exception gets handled here: and here: |
Member
Author
|
I have a fix for branch-2.8 in lhotari@1a350804 . I'll make similar changes to this PR since they aren't 2.8 specific. |
lhotari
marked this pull request as ready for review
December 3, 2021 09:40
Member
Author
|
@codelipenghui @eolivelli Please review the recent changes. |
eolivelli
reviewed
Dec 3, 2021
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
Member
Author
|
PR to backport this fix to branch-2.8 is #13117 |
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Dec 3, 2021
…ache#13117) (cherry picked from commit 537dee1)
lhotari
added a commit
that referenced
this pull request
Dec 3, 2021
lhotari
added a commit
that referenced
this pull request
Dec 3, 2021
* Add warning log message when leader broker isn't available * Add more logging about load manager decisions * Use cached information for available brokers * Reproduce lookup race issue * Use java.util.concurrent.Phaser to increase the chances of a race * Address review feedback * Increase concurrency of test case to reproduce race conditions * Use real Zookeeper server in MultiBrokerLeaderElectionTest * Add retry with backoff to loading namespace bundles * Add more topics to test * Address review comment * Fix checkstyle * Improve logging * Address review comments (cherry picked from commit 537dee1)
fxbing
pushed a commit
to fxbing/pulsar
that referenced
this pull request
Dec 19, 2021
* Add warning log message when leader broker isn't available * Add more logging about load manager decisions * Use cached information for available brokers * Reproduce lookup race issue * Use java.util.concurrent.Phaser to increase the chances of a race * Address review feedback * Increase concurrency of test case to reproduce race conditions * Use real Zookeeper server in MultiBrokerLeaderElectionTest * Add retry with backoff to loading namespace bundles * Add more topics to test * Address review comment * Fix checkstyle * Improve logging * Address review comments
aloyszhang
pushed a commit
to aloyszhang/pulsar
that referenced
this pull request
Aug 5, 2022
…!64) Squash merge branch 'optimize-ownership-assign' into '2.8.1' --story=872733891 负载均衡优化(apache#13069)(apache#13117 ) TAPD: --story=872733891
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.
Motivation
This PR depends on #13066 .
When a lookup is made to a topic that isn't currently loaded, the decision will be made in a distributed fashion on the follower brokers since the information about the leader broker is missing (because
LeaderElectionService.getCurrentLeader()always returned Optional.empty()). This leads to races when assigning the topic ownership to a broker, since the decision isn't made centrally on the leader broker.This PR adds a test to verify the behavior and also uses a cached way to get available brokers.
Modifications
MultiBrokerLeaderElectionTest.shouldProvideConsistentAnswerToTopicLookupNamespaceService.searchForCandidateBrokerLoadManager.getAvailableBrokersinstead of reading the list every time from ZookeeperAdditional context
PR to backport this fix to branch-2.8 is #13117 . Pulsar 2.8.1 contains another topic ownership bug which is fixed by #12650 .