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

[Bug] The service enters an infinite loop of metadata cache cleanup under frequent registration. #15087

Open
3 of 4 tasks
QingJuBaiTang opened this issue Jan 22, 2025 · 1 comment · May be fixed by #15086
Open
3 of 4 tasks
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@QingJuBaiTang
Copy link
Contributor

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.5
Jdk 1.8
Linux

Steps to reproduce this issue

  1. Manually perform some service registrations, such as registering one service every 10 seconds, for a total of 20 registrations.
  2. Wait for about 5 minutes, and the CPU usage will reach 100%.

What you expected to happen

Without any abnormal conditions, the CPU usage will not reach 100%.

Anything else

The reason is likely that the following code has entered an infinite loop.

// org.apache.dubbo.registry.client.AbstractServiceDiscovery
while (metadataInfos.size() > metadataInfoCacheSize) {
    AtomicReference<String> oldestRevision = new AtomicReference<>();
    AtomicReference<MetadataInfoStat> oldestStat = new AtomicReference<>();
    metadataInfos.forEach((k, v) -> {
        if (System.currentTimeMillis() - v.getUpdateTime() > metadataInfoCacheExpireTime &&
            (oldestStat.get() == null || oldestStat.get().getUpdateTime() > v.getUpdateTime())) {
            oldestRevision.set(k);
            oldestStat.set(v);
        }
    });
    if (oldestStat.get() != null) {
        metadataInfos.remove(oldestRevision.get(), oldestStat.get());
    }
}

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

@QingJuBaiTang QingJuBaiTang added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Jan 22, 2025
@heliang666s
Copy link
Contributor

@funky-eyes PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

2 participants