[WIP] Fix race condition in CuratorDruidLeaderSelector#16544
[WIP] Fix race condition in CuratorDruidLeaderSelector#16544kfaraz wants to merge 3 commits intoapache:masterfrom
CuratorDruidLeaderSelector#16544Conversation
CuratorDruidLeaderSelector
|
This pull request has been marked as stale due to 60 days of inactivity. |
|
This pull request has been marked as stale due to 60 days of inactivity. |
|
This pull request/issue has been closed due to lack of activity. If you think that |
Description
There is a race condition in
CuratorDruidLeaderSelectorwhich may occur as follows:LeaderLatchListener.isLeader()is called which callsDruidLeaderSelector.Listener.becomeLeader()listener.becomeLeader()failsCuratorDruidLeaderSelector.isLeader()is called and returnsfalsebutCuratorDruidLeaderSelector.getCurrentLeader()returns self, because the leader latch has not been updated yetLeaderLatchis recreated and updated atomicallygetCurrentLeader()returnnulluntil some other node is elected leaderFix
leader = trueonly afterlistener.becomeLeader()has succeedednullingetCurrentLeader()ifleader = falseandLeaderLatch.getLeader()returns selfOther changes
CuratorDruidLeaderSelectorK8sDruidLeaderSelector