[Bug] fix AbortPolicyWithReport may repeatedly jstack when threadPool is exhausted
- 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 Java 3.2.12
### Steps to reproduce this issue
- run test case ```jStack_ConcurrencyDump_Active_10MinSilence```, error will occurred immediately
```java
@Test
void jStack_ConcurrencyDump_Active_10MinSilence() {
URL url = URL.valueOf("dubbo://admin:hello1234@10.20.130.230:20880/context/path?dump.directory=/tmp&version=1.0.0&application=morgan&noValue=");
AtomicInteger jStackCount = new AtomicInteger(0);
AtomicInteger finishedCount = new AtomicInteger(0);
AbortPolicyWithReport abortPolicyWithReport = new AbortPolicyWithReport("Test", url) {
@Override
protected void jstack(FileOutputStream jStackStream) {
jStackCount.incrementAndGet();
try {
Thread.sleep(3000);
} catch (Exception e) {
}
}
};
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
4,
4,
0,
TimeUnit.MILLISECONDS,
new SynchronousQueue<>(),
new NamedInternalThreadFactory("jStackRepeatFixedTest", false),
abortPolicyWithReport);
List> futureList = new LinkedList<>();
for (int pos = 0; pos < 100; pos++) {
try {
futureList.add(threadPoolExecutor.submit(() -> {
finishedCount.incrementAndGet();
}));
} catch (Exception ignored) {
}
}
futureList.stream().forEach(f -> {
try {
f.get(1000, TimeUnit.MILLISECONDS);
} catch (Exception ignored) {
}
});
System.out.printf("finishedCount: %d, jStackCount: %d\n", finishedCount.get(), jStackCount.get());
Assertions.assertEquals(jStackCount.get(), 1);
}
```
### What you expected to happen
```jStackCount``` must equal ```1```, because ```AbortPolicyWithReport``` will silence ```TEN_MINUTES_MILLS``` to avoid jstack's count
### Anything else
This issue may cause JVM hang for a short time, it should be fixed as soon as possible!
### 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
Research direction
Start with the AbortPolicyWithReport entry point and run the named jStack_ConcurrencyDump_Active_10MinSilence test to reproduce repeated dumps when the ThreadPoolExecutor is exhausted. Done means the test observes jStackCount equal to 1 while preserving the expected rejection behavior and avoiding the reported short JVM hang.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100