apache / apache/dubbo

[Bug] Metrics Initialization Causing Flaky Tests in `dubbo-config/dubbo-config-api`

Open
#15,795 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Java
Stars
41.6k
Forks
26.4k
Avg merge
15h 13m
Merged PRs (30d)
4

Description

### Pre-check

- [x] I am sure that all the content I provide is in English.

### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.

### Apache Dubbo Component

Java SDK (apache/dubbo)

### Dubbo Version

Dubbo 3.3.7
JDK 17/21

### Steps to reproduce this issue

Several tests across `dubbo-config/dubbo-config-api` exhibit flaky behavior when execution order or JVM internal iteration order changes. These flakes were consistently reproduced using:

```bash
./mvnw -q -pl dubbo-config/dubbo-config-api \
edu.illinois:nondex-maven-plugin:2.2.1:nondex \
-DnondexRuns=20
```

### What you expected to happen

The reason for the flakiness are below:

**Micrometer metrics subsystem initialization**
- `CompositeMeterRegistry` uses mutable global structures
- `IdentityHashMap` iteration order varies
- Metrics are initialized implicitly during `DubboBootstrap.start()`

**DubboBootstrap global state not reset across tests**
- ApplicationModel / FrameworkModel carry over state
- Reference cache survives between tests
- System properties affect bootstrap behavior if not cleared

### Anything else

I have opened several PR's for solving the issue. I opened one PR per test file. The PRs below have been accepted:

- https://github.com/apache/dubbo/pull/15778
- https://github.com/apache/dubbo/pull/15782
- https://github.com/apache/dubbo/pull/15785

The rest of the PR's mentioned below are open for review and follow the same method to solving the flakiness used in the PRs that were accepted above:

- https://github.com/apache/dubbo/pull/15787
- https://github.com/apache/dubbo/pull/15789
- https://github.com/apache/dubbo/pull/15790
- https://github.com/apache/dubbo/pull/15791
- https://github.com/apache/dubbo/pull/15792
- https://github.com/apache/dubbo/pull/15793
- https://github.com/apache/dubbo/pull/15794

### Are you willing to submit a pull request to fix on your own?

- [x] Yes I am willing to submit a pull request on my own!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Start with the dubbo-config/dubbo-config-api module and reproduce the flakes using the provided NonDex Maven command. Review the accepted PRs 15778, 15782, and 15785 alongside open PRs 15787–15794 to identify the remaining test files and established fix pattern; done means the affected tests no longer vary across repeated NonDex runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.