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] fix AbortPolicyWithReport may repeatedly jstack when threadPool is exhausted #14467

Open
4 tasks done
code4china opened this issue Jul 23, 2024 · 1 comment
Open
4 tasks done
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@code4china
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 Java 3.2.12

Steps to reproduce this issue

  • run test case jStack_ConcurrencyDump_Active_10MinSilence, error will occurred immediately
@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<Future<?>> 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?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@code4china code4china added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Jul 23, 2024
@wcy666103
Copy link
Contributor

Can you help us fix this by submitting a pr?

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

No branches or pull requests

2 participants