Skip to content

[Bug] broadcast.fail.percent=0 does not stop the broadcast at the first failure #16515

Open

Description

@CCCLL

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

3.3 branch (ae809de), 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":

// 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:

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?

  • Yes I am willing to submit a pull request on my own!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions