-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[fix][client] Fix ArrayIndexOutOfBoundsException when using SameAuthParamsLookupAutoClusterFailover #23336
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
base: master
Are you sure you want to change the base?
Conversation
Any chance to add a test case? |
@poorbarcode @Technoboy- any chance to handle this? |
@@ -123,7 +130,7 @@ private int firstHealthyPulsarService() { | |||
} | |||
|
|||
private int findFailoverTo() { | |||
for (int i = currentPulsarServiceIndex + 1; i <= pulsarServiceUrlArray.length; i++) { | |||
for (int i = currentPulsarServiceIndex + 1; i < pulsarServiceUrlArray.length; i++) { |
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.
Just wondering if this logic is correct in the first place. Shouldn't this wrap around the array?
the for loop in checkPulsarServices
looks strange too.
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.
The logic of fallover is follows
- if the current cluster is the highest priority cluster and it is healthy, do nothing.
- else if there is a healthy and high priority cluster, recover to the higher priority one.
- else if both current cluster and higher priority clusters are not healthy, find a healthy cluster to fallover to.
So the two method checkPulsarServices
and findFailoverTo
are for the different cases to same CPU resouces.
checkPulsarServices
is for checking whether their is a healthy and high priority cluster.findFailoverTo
is for checking whether their has a cluster is healthy.
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.
@poorbarcode what happens in the case where currentPulsarServiceIndex
is already the last one? How can it find a failover cluster in that case?
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.
what happens in the case where currentPulsarServiceIndex is already the last one? How can it find a failover cluster in that case?
It will transfer to the first healthy cluster. Once encounters the ArrayIndexOutOfBoundsException
error, it means no cluster is healthy.
The issue the correct PR solved affects nothing
@poorbarcode Do you have a chance to follow up on the review comment? |
Answered here: #23336 (comment) |
…kupAutoClusterFailover
8057c39
to
471669d
Compare
Rebase master |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #23336 +/- ##
============================================
+ Coverage 73.57% 74.37% +0.80%
- Complexity 32624 35036 +2412
============================================
Files 1877 1944 +67
Lines 139502 147334 +7832
Branches 15299 16258 +959
============================================
+ Hits 102638 109583 +6945
- Misses 28908 29286 +378
- Partials 7956 8465 +509
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Motivation
There is a mistake in
SameAuthParamsLookupAutoClusterFailover.class
, which may cause aArrayIndexOutOfBoundsException
, but it affects nothing because it only happens when no server is available.Modifications
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: x