-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
component/need-triageNeed maintainers to triageNeed maintainers to triagetype/need-triageNeed maintainers to triageNeed maintainers to triage
Description
Pre-check
- I am sure that all the content I provide is in English.
Search before asking
- I had searched in the issues and found no similar issues.
Apache Dubbo Component
Java SDK (apache/dubbo)
Dubbo Version
Dubbo 3.2.12 + nacos-client 2.3.2, registration mode of the dubbo servers are interface,Jdk17
Steps to reproduce this issue
- start dubbo servers which register-mode are interface only.
- login nacos registation center, switch dubbo server interface status to offline.
- set dubbo client app breakpoints.
(1) at org.apache.dubbo.registry.integration.RegistryDirectory#refreshInvoker
private void refreshInvoker(List<URL> invokerUrls) {
Assert.notNull(invokerUrls, "invokerUrls should not be null");
if (invokerUrls.size() == 1
&& invokerUrls.get(0) != null
&& EMPTY_PROTOCOL.equals(invokerUrls.get(0).getProtocol())) {
// set first breakpoint at next refreshRouter(...) statement. <<<============================= SEE HERE !!!
refreshRouter(
BitList.emptyList(), () -> this.forbidden = true // Forbid to access
);
destroyAllInvokers(); // Close all invokers
(2) at org.apache.dubbo.registry.nacos.NacosRegistry#doSubscribe
private void doSubscribe(final URL url, final NacosAggregateListener listener, final Set<String> serviceNames) {
try {
if (isServiceNamesWithCompatibleMode(url)) {
/**
* Get all instances with serviceNames to avoid instance overwrite and but with empty instance mentioned
* in https://github.com/apache/dubbo/issues/5885 and https://github.com/apache/dubbo/issues/5899
*
* namingService.getAllInstances with
* {@link org.apache.dubbo.registry.support.AbstractRegistry#registryUrl}
* default {@link DEFAULT_GROUP}
*
* in https://github.com/apache/dubbo/issues/5978
*/
for (String serviceName : serviceNames) {
List<Instance> instances =
namingService.getAllInstances(serviceName, geturl("").getGroup(Constants.DEFAULT_GROUP));
notifySubscriber(url, serviceName, listener, instances);
}
// set second breakpoint at next for(...) statement. <<<============================= SEE HERE !!!
for (String serviceName : serviceNames) {
subscribeEventListener(serviceName, url, listener);
}
- start dubbo client app under debug mode, and it will run to first breakpoint which will set the forbidden flag to true.
- continue dubbo client app running to second breakpoint which will subscribe event listener.
- switch all dubbo server interface status to online at nacos registation center, and wait about a few seconds (let's say 10 seconds) to ensure nacos registration center finish notifying providers changing.
- continue dubbo client app running.
- as forbidden value of RegistryDirectory is always true, the dubbo client app will encouter the RpcException with 'No provider available from registry' whenever calling the dubbo server interface.
at org.apache.dubbo.registry.integration.DynamicDirectory#doList
@Override
public List<Invoker<T>> doList(
SingleRouterChain<T> singleRouterChain, BitList<Invoker<T>> invokers, Invocation invocation) {
// >>> the value of forbidden is always true. <<<
if (forbidden && shouldFailFast) {
// 1. No service provider 2. Service providers are disabled
throw new RpcException(
RpcException.FORBIDDEN_EXCEPTION,
"No provider available from registry " + this
+ " for service " + getConsumerurl("").getServiceKey() + " on consumer "
+ NetUtils.getLocalHost()
+ " use dubbo version " + Version.getVersion()
+ ", please check status of providers(disabled, not registered or in blocklist).");
}
What you expected to happen
moving subscribeEventListener calling statement of NacosRegistry#doSubscribe prior to notifySubscriber might solve this issue. just like ZookeeperRegistry#doSubscribe did.
Anything else
this issue has existed in dubbo2 and dubbo3 for a long time and many contributers proposed revision suggestions. I wonder why not made any revisions to this issue.
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
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
component/need-triageNeed maintainers to triageNeed maintainers to triagetype/need-triageNeed maintainers to triageNeed maintainers to triage
Type
Projects
Status
Done