Pre-check
- [x] I am sure that all the content I provide is in English.
Search before asking
- [x] I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
dubbo 3.2.5 dubbo 3.3.4
Steps to reproduce this issue
There is one consumer (demo-consumer
) and two providers (demo-provider
and demo-provider2
).
Both providers implement the org.example.DemoService
interface, and the consumer continuously calls this interface in a loop.
To make the results easier to observe, I customized a router via SPI so that the consumer only routes calls to instances of demo-provider2
.
At the beginning, only demo-provider
is running, so all consumer calls fail. After demo-provider2
comes online, the expected behavior is that the consumer should then be able to successfully make calls — but in reality, it still fails.
One special thing I noticed is that I created two references to DemoService
in the consumer. One reference is able to call demo-provider2
successfully, while the other still fails.
To reliably reproduce the issue, you must:
1. Delete the .dubbo
folder under your home directory before starting the experiment.
2. Remove demo-provider2
from the org.example.DemoService
mapping file.
This problem only occurs the first time demo-provider2
comes online.
I have created two demo projects to reproduce the issue: - https://gitee.com/BaiTang010/dubbo-provider - https://gitee.com/BaiTang010/dubbo-consumer
How to start the two providers:
java -jar -DappName=demo-provider -Dport=20880 target/provider.jar
java -jar -DappName=demo-provider2 -Dport=20881 target/provider.jar
What you expected to happen
everything goes fine
Anything else
No response
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!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Comment From: songxiaosheng
What is the error message running on your rpc call
Comment From: QingJuBaiTang
Before starting demo-provider2, the output is:
demo service, failed
demo service 2, failed
demo service, failed
demo service 2, failed
demo service, failed
demo service 2, failed
After demo-provider2 is started, the output changes to:
demo service, success
demo service 2, failed
demo service, success
demo service 2, failed
Comment From: zrlw
could you debug the consumer application and get the full stacktrace of the exception that was thrown?
try {
String res= demoService.sayHi("");
System.out.println("demo service, success");
} catch (Throwable t) {
t.printStackTrace();
System.out.println("demo service, failed");
}
...
Comment From: QingJuBaiTang
could you debug the consumer application and get the full stacktrace of the exception that was thrown?
try { String res= demoService.sayHi(""); System.out.println("demo service, success"); } catch (Throwable t) { t.printStackTrace(); System.out.println("demo service, failed"); } ...
No provider...
Comment From: zrlw
could you upload full debug level log?
Comment From: zrlw
you'd better check your MultiProviderRouter.java again, add logging codes to see invokers list is empty or not.
Comment From: zrlw
i tested your codes with current dubbo 3.3 branch and didn't find the issue. maybe you should try the current version. What i changed: 1. modify pom.xml for running springboot testing on zookeeper
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>3.3.4-SNAPSHOT</version> <!-- mvn install on current dubbo 3.3 branch -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.2.3</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-zookeeper-curator5-spring-boot-starter</artifactId>
<version>3.3.4-SNAPSHOT</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.nacos</groupId>-->
<!-- <artifactId>nacos-client</artifactId>-->
<!-- <version>2.1.0</version>-->
<!-- </dependency>-->
- add output to MultiProviderRouter.java
public class MultiProviderRouter extends AbstractRouter {
@Override
public <T> RouterResult<Invoker<T>> route(List<Invoker<T>> invokers,
URL url,
Invocation invocation,
boolean needToPrintMessage) throws RpcException {
List<Invoker<T>> filteredInvokers = new ArrayList<>();
System.out.println("invokers cnt: " + invokers.size());
for (Invoker<T> invoker : invokers) {
System.out.println("invoke: " + invoker);
URL invokerUrl = invoker.getUrl();
System.out.println("invokeUrl: " + invokerUrl);
if (invokerUrl instanceof InstanceAddressURL) {
InstanceAddressURL instanceAddressURL = (InstanceAddressURL) invokerUrl;
String serviceName = instanceAddressURL.getInstance().getServiceName();
System.out.println("invokeUrl serviceName: " + serviceName);
if (serviceName.equals("demo-provider2")) {
System.out.println("add to filtered invokers " + invoker);
filteredInvokers.add(invoker);
}
}
}
my test step (all steps just run only once time) : step1. start provider on 20880 java -jar -DappName=demo-provider -Dport=20880 target/provider.jar step2: start consumer java -jar target/consumer.jar step3: start provider on 20881 java -jar -DappName=demo-provider2 -Dport=20881 target/provider.jar output:
Comment From: QingJuBaiTang
I tested it on the latest version 3.3.5, and the issue still exists. Please use Nacos as the registry and metadata center — the problem is likely related to Nacos's implementation.
Comment From: zrlw
maybe you should upgrade your nacos to 2.5.1 to avoid the bugs existed in early nacos2.x,
by the way, i changed a little codes: i added @EnableDubbo
and @SpringBootApplication
annotations to the provider, add @DubboService
to the service implements.
Comment From: QingJuBaiTang
I upgraded Nacos to 2.5.1, but it still doesn't work. Also, since we've added some custom wrappers based on Dubbo, we don't directly use annotations like @EnableDubbo or @DubboService
Comment From: zrlw
i tested under nacos 2.5.1 enviroment (both client and server use 2.5.1) and got same successful result. 1. modified provider and consumer pom to support nacos 2.5.1
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>3.3.6-SNAPSHOT</version> <!-- mvn install on dubbo current 3.3 branch: 2025/06/20 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.2.3</version>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>2.5.1</version>
</dependency>
<!-- incompatible -->
<!-- <dependency>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-api</artifactId>-->
<!-- <version>1.7.36</version>-->
<!-- </dependency>-->
- add annotations:
@EnableDubbo
@DubboService
@SpringBootApplication
to provider. - test
step 1: delete .dubbo at home directory
step 2: start nacos 2.5.1 server
step 3: clean all mapping files under ${home}/nacos/config/Config-fixed-X.X.X.X_8848_nacos/snapshot
step 4: start provider on 20880, java -jar -DappName=demo-provider -Dport=20880 target/provider.jar
step 5: start consumer, java -jar target/consumer.jar
step 6: check the org.example.DemoService mapping file again, if it contains demo-provider2 then remove it
step 7: start provider on 20881, java -jar -DappName=demo-provider2 -Dport=20881 target/provider.jar
- get consumer output
As for me, you might focus Nacos bugfix notification from Nacos: https://github.com/alibaba/nacos/releases
Comment From: QingJuBaiTang
Could you test it without modifying the code I provided (except for upgrading the Dubbo and Nacos versions)? Or is there anything unreasonable in my original implementation? In our actual project, we don't directly use Dubbo's Spring Boot starter.
Comment From: zrlw
may be you should create a simple project without your wrappers to test which part is in trouble. it seemed your issue has nothing to do with dubbo.