CCCLL opened a new pull request, #16516: URL: https://github.com/apache/dubbo/pull/16516
## What is the purpose of the change? Fixes #16515. `BroadcastClusterInvoker` stops calling providers once the number of failures reaches `invokers.size() * broadcast.fail.percent / 100`. The code comment documents `0` as "as long as an exception occurs, it will be thrown", but with a threshold of 0 the check `failIndex == failThresholdIndex` never matches: `failIndex` is incremented before the comparison, so it is at least 1. The broadcast therefore calls every provider, like the default of 100. The same happens for any percentage that rounds down to a threshold of 0, for example 10 with four providers. This PR compares with `>=` in the two break checks and in the debug log that reports whether the threshold was reached. Non-zero thresholds behave as before: `failIndex` grows by one per failure, so the loop already broke exactly when it reached them. ## Verification - New `BroadCastClusterInvokerTest#testZeroFailPercent` fails before the change (`invoker2` is invoked) and passes after it. - `mvn test -pl dubbo-cluster`: 307 tests, 0 failures (13 skipped, as on the base branch); spotless and checkstyle are clean. - A temporary exhaustive check (not committed) over 1 to 6 providers, every percentage from 0 to 100 and every failure pattern: before the change, 2308 of the 12726 combinations invoked more providers than the threshold allows, all of them with a computed threshold of 0; after the change every combination stops right after the `max(1, threshold)`-th failure. - End to end, with four real Dubbo-protocol providers that all throw and a `cluster=broadcast` reference: | `broadcast.fail.percent` | providers invoked before | providers invoked after | |---|---|---| | 0 | 4 of 4 | 1 of 4 | | 75 | 3 of 4 | 3 of 4 | | 100 | 4 of 4 | 4 of 4 | ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project. - [ ] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
