Skip to content

Naming local cache may be ignored in a rare scenario #12644

@nkorange

Description

@nkorange

Describe the bug

Naming local cache may be ignored in a rare scenario. So even when local cache is not empty, user's invocation would still get exception.

Expected behavior

If local cache is not empty, Nacos client should never throw exception.

Actually behavior

In a rare case, when local cache is not empty, user's invocation would get exception.

How to Reproduce

It's hard to reproduce but it did happen in our production environment. Here is the related logic:

in the method at getServiceInfoBySubscribe:

  1. first it tried to get service info from local cache;
  2. then it will check if local cache is null or client is not subscribed:
image 3. if yes, it will try to subscribe from remote Nacos server.

Usually it will work, because whenever clientProxy.isSubscribed(...) returns false, it means the Nacos client has just reconnected to Nacos server and closed the old connection:
image

As new connection is ready, so the subscribe request would succeed.

But if the new connection is down immediately again so the subscribe request failed, then in the method getServiceInfoBySubscribe, an exception will be thrown.

Desktop (please complete the following information):

  • OS: [e.g. Centos]
  • Version: nacos-server 2.1.2, nacos-client 2.1.2
  • Module: naming
  • SDK: spring-cloud-alibaba-nacos 2021.1

Additional context

I suggest to add a protection logic in the method getServiceInfoBySubscribe, so that whenever the local cache is not empty, the remote request error or any other exception will be ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/discussionCategory issues related to discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions