zrlw commented on issue #11286:
URL: https://github.com/apache/dubbo/issues/11286#issuecomment-2561679805

   the issue is trigged when both consumer and provider start up at the same 
time by these steps:
   ```
              consumer-A (running at NacosRegistry#doSubscribe)           
provider-B and nacos registration center
        1.   get empty instance list of the provider 
              by namingService.getAllInstances.
        3.   set the value of forbidden to true
              by calling notifySubscriber -> RegistryDirectory#refreshInvoker
                                                                     4. 
register instance to nacos registration center
                                                                     5. nacos 
registration center send instance info
                                                                         to the 
subcribers except consumer-A
                                                                         as it 
does not subscribe yet.
        6. subsribe instance info of provider-B later.
            but it will receive nothing and  'No provider' RpcException
            will be thrown whenever calling provider-B as the value of 
forbidden is always true.
   ```
    @riflechan 能debug确认一下吗?把subscribeEventListener挪到notifySubscriber前面能解决这个问题么?
   the issue might be fixed by calling notifySubscriber before getAllInstances 
like this?
   ```
                   // subscribe first to avoid missing event notice?
                   for (String serviceName : serviceNames) {
                       subscribeEventListener(serviceName, url, listener);
                   }
                   
                   for (String serviceName : serviceNames) {
                       List<Instance> instances = 
namingService.getAllInstances(serviceName,
                               getUrl().getParameter(GROUP_KEY, 
Constants.DEFAULT_GROUP));
                       
NacosInstanceManageUtil.initOrRefreshServiceInstanceList(serviceName, 
instances);
                       notifySubscriber(url, listener, instances);
                   }
   ```
   


-- 
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]

Reply via email to