8380103: Perfdata shared memory file flock failures#30537
8380103: Perfdata shared memory file flock failures#30537caspernorrbin wants to merge 2 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into |
|
@caspernorrbin 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 86 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 |
|
@caspernorrbin The following label 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 list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
dholmes-ora
left a comment
There was a problem hiding this comment.
This seems quite reasonable to me. Thanks for fixing this nuisance issue.
One minor suggestion below, and one issue in the test.
| out2.getStdout().contains(s2) || | ||
| out2.getStdout().contains(s2)); |
There was a problem hiding this comment.
Should one of those be out1?
There was a problem hiding this comment.
Yes it definitely should! Fixed now. The reason it worked is because out2 is from the second process which is almost always the one that contains the output.
| // still be starting up and are therefore not candidates for stale-file | ||
| // cleanup. This avoids racing a concurrent JVM startup while scanning the | ||
| // hsperfdata directory. | ||
| static const time_t cleanup_grace_period_seconds = 5; |
There was a problem hiding this comment.
A drive-by comment, how did you determine this value?
There was a problem hiding this comment.
Very arbitrarily. It could probably be a bit lower, but I wanted to give a bit of a buffer in case some weird behaviour happens when we start a lot of VMs concurrently.
There was a problem hiding this comment.
I understand that, so by the log message if needed we'll be able to tell if it sufficient in most cases. If nothing pops up, then yes.
Hi everyone,
The existing posix hsperfdata logic has a potential race between stale-file cleanup and new file creation. During startup, a JVM first scans the hsperfdata directory and cleans up old files before creating its own file. While one JVM is scanning the directory and probing pid files to decide whether they are stale, another JVM may already have created its own file but not yet acquired the flock on it. Because ownership is established with an open followed by a flock, the cleanup path can briefly win that race on a freshly created file and cause the creating JVM to fail its own flock. The same locking protocol is also used to distinguish stale files from live JVMs in other pid namespaces when multiple containers share the same /tmp.
To reduce this race window, I have made the cleanup path more conservative with file removals, and the startup path more tolerant of collisions. The cleanup sweep now checks file modification time and avoids touching files that were recently modified, so we do not try to flock and remove files that are likely still in use or have just been created. In addition, if
create_sharedmem_file()loses the initial flock withEWOULDBLOCK, it now retries a small number of times with a short delay before giving up, which gives a concurrent cleanup JVM time to release the lock.Together these changes make the race much less likely to affect startup. Files that were just created are left out of the cleanup sweep, and even if they were to get probed, the creating JVM would still eventually get to flock it. If a stale file that should have been removed isn't, it is still going to get cleaned up eventually with the next JVM start. I also updated the
ShareTmpDir.javatest, as with these changes we do not try and remove the file, which results in a different log output.Testing:
asserts added to ensure we can always create and flock the hsperfdata fileProgress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30537/head:pull/30537$ git checkout pull/30537Update a local copy of the PR:
$ git checkout pull/30537$ git pull https://git.openjdk.org/jdk.git pull/30537/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30537View PR using the GUI difftool:
$ git pr show -t 30537Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30537.diff
Using Webrev
Link to Webrev Comment