CCCLL opened a new issue, #16515:
URL: https://github.com/apache/dubbo/issues/16515
### Apache Dubbo Component
Java SDK (apache/dubbo)
### Dubbo Version
`3.3` branch (ae809de2fc), OpenJDK 21, macOS. The threshold check has not
changed since `broadcast.fail.percent` was added in #7174 (2.7.9).
### Steps to reproduce this issue
`BroadcastClusterInvoker` documents `broadcast.fail.percent=0` as "throw as
soon as an exception occurs":
```java
// The value range of broadcast.fail.threshold must be 0~100.
// 100 means that an exception will be thrown last, and 0 means that as long
as an exception occurs, it will be
// thrown.
```
Export one service on four Dubbo-protocol ports, with an implementation that
always throws, and call it through a broadcast reference:
```java
ReferenceConfig<Echo> reference = new ReferenceConfig<>();
reference.setInterface(Echo.class);
reference.setUrl("dubbo://127.0.0.1:21081;dubbo://127.0.0.1:21082;dubbo://127.0.0.1:21083;dubbo://127.0.0.1:21084");
reference.setCluster("broadcast");
reference.setParameters(Collections.singletonMap("broadcast.fail.percent",
"0"));
```
Number of providers invoked for one call, depending on
`broadcast.fail.percent`:
```
broadcast.fail.percent=0 -> 4 of 4 providers invoked
broadcast.fail.percent=25 -> 1 of 4
broadcast.fail.percent=75 -> 3 of 4
broadcast.fail.percent=100 -> 4 of 4
```
So `0` stops later than `25` and behaves like the default of `100`. Any
percentage that rounds down to a threshold of 0 behaves the same way, for
example `10` with four providers.
### What you expected to happen
With `broadcast.fail.percent=0`, the broadcast should throw right after the
first failed provider, so only one of the four providers is invoked.
### Anything else
The threshold is computed as `invokers.size() * broadcastFailPercent / 100`,
which is 0 here, and the loop stops only when `failIndex ==
failThresholdIndex`. `failIndex` is incremented before that comparison, so it
is at least 1 and never equals 0: the loop never stops early.
Comparing with `>=` fixes the zero case and leaves every non-zero threshold
unchanged.
### Are you willing to submit a pull request to fix on your own?
- [x] Yes I am willing to submit a pull request on my own!
--
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]