[Broker] Fix LeaderElectionService.getCurrentLeader and add support for empheralOwner in MockZooKeeper - #13066
Conversation
@eolivelli yes, 2.8.x and 2.9.x are also impacted. |
|
BTW: I also plan to get rid of MockZookeeper in the short term :) |
@merlimat +1, that would reduce the risk that it's the MockZookeeper that causes certain behavior in tests. |
Yes, the way it is, it doesn't help much. We've been chasing down many times issues that stemmed from it semantic being different from the real ZK in subtle ways. For unit tests, I believe the LocalMemory is a better alternative, although we need to add the ephemeral owner there too. |
|
Closing and reopening to get fix to flaky test for builds. |
dad26de to
e266578
Compare
e266578 to
f68da4c
Compare
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.BeforeClass; | ||
|
|
||
| public abstract class MultiBrokerBaseTest extends MockedPulsarServiceBaseTest { |
There was a problem hiding this comment.
nit:
this is actually not a "Test", we should not name it "**Test"
btw this is the current code style in Pulsar, so no big deal, just sharing this thought
|
@linlinnn we must pick this patch to branch-2.8 before cutting a release. 2.8 is too unstable due to this problem |
…or empheralOwner in MockZooKeeper (#13066) * Add leader election unit test that uses multiple brokers * Support empheralOwner in MockZooKeeper * Use unique sessions for all brokers * Add failing test case for leader broker information not available on other brokers * Add test for reading the current leader * Fix issue in leader election * Address review feedback: make methods static * Use unique-session only in MultiBrokerBaseTests * Move tenant and namespace creation to it's own method * Improve cleanup * Add alwaysRun to BeforeClass * Fix leaks in locking in MockZooKeeper * Reduce code duplication * Fix NPE when CreateMode is null (cherry picked from commit 36a45ee)
…or empheralOwner in MockZooKeeper (#13066) * Add leader election unit test that uses multiple brokers * Support empheralOwner in MockZooKeeper * Use unique sessions for all brokers * Add failing test case for leader broker information not available on other brokers * Add test for reading the current leader * Fix issue in leader election * Address review feedback: make methods static * Use unique-session only in MultiBrokerBaseTests * Move tenant and namespace creation to it's own method * Improve cleanup * Add alwaysRun to BeforeClass * Fix leaks in locking in MockZooKeeper * Reduce code duplication * Fix NPE when CreateMode is null (cherry picked from commit 36a45ee)
|
@eolivelli @linlinnn I cherry picked to branch-2.8 and branch-2.9 . |
|
@linlinnn @eolivelli PR #13069 would also be necessary for 2.8 to fix the problems with topic ownership assignments. |
…or empheralOwner in MockZooKeeper (apache#13066) * Add leader election unit test that uses multiple brokers * Support empheralOwner in MockZooKeeper * Use unique sessions for all brokers * Add failing test case for leader broker information not available on other brokers * Add test for reading the current leader * Fix issue in leader election * Address review feedback: make methods static * Use unique-session only in MultiBrokerBaseTests * Move tenant and namespace creation to it's own method * Improve cleanup * Add alwaysRun to BeforeClass * Fix leaks in locking in MockZooKeeper * Reduce code duplication * Fix NPE when CreateMode is null (cherry picked from commit 36a45ee) (cherry picked from commit 72690be)
- fixes cherry picking of apache#13066 in 72690be (cherry picked from commit 59d8ad9)
…951) Fix https://github.com/streamnative/kop/runs/4425667410?check_suite_focus=true#step:5:283 #950 ### Motivation MockZookeeper API was changed in apache/pulsar#13066, the `CreateMode` shouldn't be null. We should use MetadataStore instead of mockZooKeeper since KoP already remove all zkClient usage. ### Modifications Use MetadataStore instead of mockZooKeeper in ProducerIdManagerTest
…951) Fix https://github.com/streamnative/kop/runs/4425667410?check_suite_focus=true#step:5:283 #950 ### Motivation MockZookeeper API was changed in apache/pulsar#13066, the `CreateMode` shouldn't be null. We should use MetadataStore instead of mockZooKeeper since KoP already remove all zkClient usage. ### Modifications Use MetadataStore instead of mockZooKeeper in ProducerIdManagerTest
…951) Fix https://github.com/streamnative/kop/runs/4425667410?check_suite_focus=true#step:5:283 #950 ### Motivation MockZookeeper API was changed in apache/pulsar#13066, the `CreateMode` shouldn't be null. We should use MetadataStore instead of mockZooKeeper since KoP already remove all zkClient usage. ### Modifications Use MetadataStore instead of mockZooKeeper in ProducerIdManagerTest
Fix #950 ### Motivation apache/pulsar#13066 introduced a breaking change to the `MockZooKeeper` API and causes test failure. ### Modifications * Fix failure test * Upgrade pulsar version to 2.8.1.0
…or empheralOwner in MockZooKeeper (apache#13066) * Add leader election unit test that uses multiple brokers * Support empheralOwner in MockZooKeeper * Use unique sessions for all brokers * Add failing test case for leader broker information not available on other brokers * Add test for reading the current leader * Fix issue in leader election * Address review feedback: make methods static * Use unique-session only in MultiBrokerBaseTests * Move tenant and namespace creation to it's own method * Improve cleanup * Add alwaysRun to BeforeClass * Fix leaks in locking in MockZooKeeper * Reduce code duplication * Fix NPE when CreateMode is null
|
Further improvement in #17401 |
Motivation
LeaderElectionService.getCurrentLeader()always returnedOptional.empty()on all other than the leader broker.This has several severe consequences in the Pulsar Broker code base.
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 returnedOptional.empty()). This leads to races when assigning the topic ownership to a broker since the decision isn't made centrally on the leader broker.I'll provide a separate PR for improving and fixing the topic ownership assignment. That PR is #13069 and it contains a failing test case for the topic ownership assignment / lookup problem.
Modifications