-
Notifications
You must be signed in to change notification settings - Fork 1
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
non recoverable state in withMultipleHostAndPort
when consuls are blacklisted
#388
Comments
I did some initial investigation into this and it definitely appears to be a 🐛 . The In So, if all targets have been blacklisted, the conditional on line 94 in After some hacking around, adding lots of logging, moving some code around, I added code in After making that change the logging shows targets getting blacklisted, and then coming out of the blacklist after the expiration period. Then they go back into the blacklist, and come out, etc. (Since With the changes to check for expiration in both places, and adding a print statement when a target is removed from the blacklist, running the sample application provided by @bt-wil results in:
You can see the errors now alternate between
So I think this fixes the problem and may be a decent solution without completely changing the code. When I get some additional time, I will clean things up, remove the absurd amount of logging I added, and create a PR. It will probably not before Christmas 🎄 though. |
It is similar to what I had did to fix the issue, but didn't spend too much on checking whether there could be some side effect.
updated: not have to create
|
Ok sounds like we're on the same page. I also don't know if there might be some side-effect since I wasn't the original author of this library. But since we both did similar things, that makes me feel better about it. I will try to find some time "soon" and push up a PR. |
* Factor duplicate logic from if and else branches in computeNextStage. * Extract blacklist expiration duration logic from findTargetNotInBlacklist to new method isPastBlacklistDuration. * Change isRequestViable to call findTargetNotInBlacklist. Because findTargetNotInBlacklist will remove a target from the blacklist if past the expiration, this now ensures a correct result. If the target is not blacklisted, then the request is viable. If it or any other target is blacklisted but past the expiration, that target is considered viable and removed from the blacklist. Only if all targets are currently in blacklist and none have expired is the request considered not viable. * Create addToBlacklist method to replace duplicate blacklist.put calls. * Create isBlacklisted method to check if a target is in blacklist. * Create isNotBlacklisted method to check if a target is not in blacklist. * Rename fromRequest to hostAndPortFromRequest for clarity. * Renamed the blacklistingConsulFailoverStrategy field in the test to just "strategy" since it is much shorter, and because the test is only related to the BlacklistingConsulFailoverStrategy. * Add more tests. Move the original tests inside a nested class ComputeNextStage. The new tests are nested inside their own nested classes for the various scenarios. I kept the tests for blacklsit expiration for computeNextStage in a separate nested class, ComputeNextStageExpiration, mainly b/c they are new and are specifically for testing the expiration logic. Also added dedicated tests for isRequest and the (internal) isPastBlacklistDuration method. Fixes #388
When using the
withMultipleHostAndPort
, there is ablacklistTime
duration. I would expect that the bad host that was blacklisted would be retried after the duration is over, but it is not the case.The issue is in https://github.com/kiwiproject/consul-client/blob/v1.4.2/src/main/java/org/kiwiproject/consul/util/failover/ConsulFailoverInterceptor.java#L94 where the viability is checked, but not take into account of the blacklist timeout. And the resetting of the timeout only happens when inside
isRequestViable
:The text was updated successfully, but these errors were encountered: