> Some Kubernetes setups share the /tmp directory across multiple containers. 
> On rare occasions, the JVM may crash when it tries to write to 
> `/tmp/hsperfdata_<user>/<pid>` when a process in a separate container decides 
> to do the same thing (because they happen to have the same namespaced pid).
> 
> This patch avoids the crash by using `flock()` to allow only one of these 
> processes to write to the file. All other competing processes that fail to 
> grab the lock will give up the file and run with PerfMemory disabled. We will 
> try to enable PerfMemory for the failed processes in a follow-up RFE: 
> [JDK-8289883](https://bugs.openjdk.org/browse/JDK-8289883)
> 
> Thanks to Vitaly Davidovich and Nico Williams for coming up with the idea of 
> using `flock()`.
> 
> I kept the use of `kill()` for stale file detection to be compatible with 
> older JVMs.
> 
> I also took the opportunity to clean up the comments and remove dead code. 
> The old code was using "shared memory resources" which sounds unclear and 
> odd. I changed the terminology to say "shared memory file" instead.

Ioi Lam has updated the pull request with a new target base due to a merge or a 
rebase. The incremental webrev excludes the unrelated changes brought in by the 
merge/rebase. The pull request contains 15 additional commits since the last 
revision:

 - Merge branch 'master' of https://github.com/openjdk/jdk into 
8286030-avoid-jvm-crash-when-containers-share-tmp-dir
 - Fixed typo in comments
 - add errno to log
 - added debug log and tweaked comment
 - fixed typo
 - added more comments
 - Simplified code and improved comments
 - @tstuefe comments
 - Merge branch 'master' into 
8286030-avoid-jvm-crash-when-containers-share-tmp-dir
 - Cleaned up comments and avoid using the word "resource" to describe the 
shared mem file
 - ... and 5 more: https://git.openjdk.org/jdk/compare/7575df9c...efc00f6e

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/9406/files
  - new: https://git.openjdk.org/jdk/pull/9406/files/ecac352b..efc00f6e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9406&range=06
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9406&range=05-06

  Stats: 85601 lines in 1888 files changed: 43830 ins; 26943 del; 14828 mod
  Patch: https://git.openjdk.org/jdk/pull/9406.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9406/head:pull/9406

PR: https://git.openjdk.org/jdk/pull/9406

Reply via email to