Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchRegister cause instance count error. #11056

Closed
KomachiSion opened this issue Aug 31, 2023 · 0 comments · Fixed by #11058
Closed

BatchRegister cause instance count error. #11056

KomachiSion opened this issue Aug 31, 2023 · 0 comments · Fixed by #11058
Assignees
Labels
area/Naming kind/bug Category issues or prs related to bug.
Milestone

Comments

@KomachiSion
Copy link
Collaborator

Describe the bug
In AbstractClient, add Instance will add instance size to monitor count for instance when register batch Instance.

    @Override
    public boolean addServiceInstance(Service service, InstancePublishInfo instancePublishInfo) {
        if (null == publishers.put(service, instancePublishInfo)) {
            if (instancePublishInfo instanceof BatchInstancePublishInfo) {
                MetricsMonitor.incrementIpCountWithBatchRegister(instancePublishInfo);
            } else {
                MetricsMonitor.incrementInstanceCount();
            }
        }
        NotifyCenter.publishEvent(new ClientEvent.ClientChangedEvent(this));
        Loggers.SRV_LOG.info("Client change for service {}, {}", service, getClientId());
        return true;
    }

But the old only add the size for first time, when batch register second times, the count will not change. And when deregister the batch instance, the count will be more or less decrease.

Expected behavior
Count right.

Actually behavior
maybe count wrong

How to Reproduce
Steps to reproduce the behavior:

  1. Start any nacos service
  2. Register any size batch instance
  3. Register any other size batch instance for same service by same client.
  4. See the prometheus api and found ipCount is not expected.
  5. close the client, and the ipCount is not 0.

Desktop (please complete the following information):

  • OS: [e.g. Centos]
  • Version [e.g. nacos-server 1.3.1, nacos-client 1.3.1]
  • Module [e.g. naming/config]
  • SDK [e.g. original, spring-cloud-alibaba-nacos, dubbo]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Naming kind/bug Category issues or prs related to bug.
Projects
None yet
1 participant