-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8303916: ThreadLists.java inconsistent results #14465
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
Conversation
👋 Welcome back kevinw! A progress list of the required criteria for merging this PR into |
@kevinjwalls The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/label remove core-libs |
@AlanBateman |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, but I'm surprised you only need to filter "ForkJoinPool" and "JVMCI". What about threads like "Common-Cleaner"?
public static boolean filtered(Event event) { |
Thanks - that's a useful reference list. For this test, it's never managed to not have Common-Cleaner in the initial set of threads it observes, I think... But it's very easy to see a couple of ForkJoinPool-x-worker-x threads, and see one more of them by the time it gets threads from the MXBean. That's the way I see it failing for us now. If we do see others appear, I hope having added the extra printing it will be easy to add other names, if they affect this test... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test assumes that it can find a set of steady-state threads running that does not change, but that is not the case. I don't find this test particularly useful in what it attempts to do. It would make more sense to have a set of test threads that it looks for via each method, and which it can control termination of and thus check that they disappear. Adding an allow-list of dynamically appearing threads seems somewhat fragile, but I guess we've really only seen two problematic scenarios:
- Running with virtual threads
- Running with JVMCI
so the fix "works".
@kevinjwalls This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 22 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
I agree with David and would be concerned this test will be whack-a-mole to deal with other cases. It would be a lot simpler to have a test that creates a number of threads, then uses Thread.getAllThreadStacks + ThreadMXBean.getAllThreadIds to that the expected list of threads are included. If the current thread is not a virtual thread then it can check that it is included too. If you really want to check that both methods return the same list of threads then I think it will need to loop + backoff when the threads aren't the same. |
Thanks for the comments and reviews. I did look at the history and this test exists because of previous confusion about thread groups, where the top thread group and the MXBean thread lists could be different. So if this test creates new threads and checks they are in both lists, it loses the original purpose as I read it. I'm not saying it's a great test. But it successfully monitored that problem since 2004, and lasted surprisingly well even before being moved to an "othervm" ! If there's any mole-whacking, I think the new logging should make it easy to see the name of the mole, and if it's a thread that's expected to appear possibly between the observations, then it can be added to the list. It is just those two new things, JVMCI and ForkJoinPool, which are known to fool it so far. We should make this change and watch for moles appearing, or indeed disappearing. |
/integrate |
Going to push as commit 8c9b85a.
Your commit was automatically rebased without conflicts. |
@kevinjwalls Pushed as commit 8c9b85a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
/backport jdk21 |
@kevinjwalls the backport was successfully created on the branch kevinjwalls-backport-8c9b85a9 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:
|
Can you elaborate what the issue was please. I would have to suspect the wrong "top" ThreadGroup was being used (main vs. system). |
Sure, this was: 5047639: threadGroup.enumerate() ignores the Signal Dispatcher thread top ThreadGroup enumerate returns one less thread than ThreadMBean's getThreadCount. Notes: SignalDispatcher started by the VM, question on whether ThreadMBean should include system threads. The test wants to ensure that thread group and mbean are consistent, it doesn't particularly look for any thread belonging to a particular group, but would be happy as long as all threads are either in both samples or neither. |
This test fails when additional threads are created, as it compares thread lists from different sources and sees a mismatch.
It needs to tolerate some threads with certain names appearing, e.g. JVMCI and ForkJoin threads. If there are extra threads in the thread ID list from the ThreadMBean, remove them from the thread count before comparing.
When it fails, additionally print the ids and names of threads that it got from the MBean.
I found the test quite confusing, the naming of thread counts, arrays of threads, and arrays of thread stacktraces from different sources, so have renamed some things.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14465/head:pull/14465
$ git checkout pull/14465
Update a local copy of the PR:
$ git checkout pull/14465
$ git pull https://git.openjdk.org/jdk.git pull/14465/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14465
View PR using the GUI difftool:
$ git pr show -t 14465
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14465.diff
Webrev
Link to Webrev Comment