-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Fix race condition in MetadataStoreCacheLoader causing inconsistent availableBroker list caching #24639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix][broker] Fix race condition in MetadataStoreCacheLoader causing inconsistent availableBroker list caching #24639
Conversation
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @zhaizhibo! Please check the review comments.
...broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
Outdated
Show resolved
Hide resolved
...broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
Outdated
Show resolved
Hide resolved
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good now. I think preserving the original logic to do the initial fetch of brokers could be useful. There's a comment about that.
...broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
Show resolved
Hide resolved
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the contribution @zhaizhibo
|
There's a checkstyle error: If you are using IntelliJ IDE, here are instructions how to setup the correct code style: https://pulsar.apache.org/contribute/setup-ide/#configure-code-style Before pushing changes, this is the fastest command to validate that the project compiles and checkstyle passes for the project: mvn -Pcore-modules,-main -T 1C clean install -DskipTests -Dspotbugs.skip=true -DnarPluginPhase=none |
done. The original log message 'Successfully updated xxx' was useful, so I added it back. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24639 +/- ##
============================================
- Coverage 74.48% 74.25% -0.24%
+ Complexity 33277 32787 -490
============================================
Files 1882 1882
Lines 146854 146859 +5
Branches 16866 16868 +2
============================================
- Hits 109389 109047 -342
- Misses 28861 29130 +269
- Partials 8604 8682 +78
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c) (cherry picked from commit a05e727)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c) (cherry picked from commit b2f12a2)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c) (cherry picked from commit b2f12a2)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com> (cherry picked from commit d3c615c) (cherry picked from commit a05e727)
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com>
…inconsistent availableBroker list caching (apache#24639) Co-authored-by: zhaizhibo <zhaizhibo@kuaishou.com>
Motivation
The second update (with 5 brokers) was actually processed before the first update (with 6 brokers), but due to concurrent operations, the incorrect result was cached.
When updating the availableBrokers in MetadataStoreCacheLoader, there is a possibility that the actual processing order of ZooKeeper updates may become inconsistent. This could occur due to:
loadReportResources.getChildrenAsync(LOADBALANCE_BROKERS_ROOT)via .thenApplyAsyncModifications
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: