RFR: 8370715: JFR: Races are possible when dumping recordings [v2]
Robert Toyonaga
duke at openjdk.org
Fri Nov 21 22:41:06 UTC 2025
> #### Summary
> This PR changes the JFR snapshot dumping code so that multiple JFR recordings (potentially from different processes) racing to write the same dump destination won't mix their data.
>
> #### Problem
> The dump destination file is created and/or wiped when a recording is started, but not wiped again before actually copying over the chunks during a dump. So in the window of time between creating/wiping and dumping chunks, another recording could write to the same dump destination and have it's chunks added to the snapshot. This can happen with either a single JVM or multiple JVMs that are racing.
>
> #### Proposed fix
> This PR ensures that any data previously written to the dump destination is wiped before the new recording's data is written. File locking is also done while chunks are being written.
>
> Testing:
> - new test `jdk/jdk/jfr/api/recording/dump/TestDumpOverwrite.java`
> - Tier 1
Robert Toyonaga has updated the pull request incrementally with one additional commit since the last revision:
small cleanup
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28460/files
- new: https://git.openjdk.org/jdk/pull/28460/files/48ec9a7f..b2ef365d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28460&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28460&range=00-01
Stats: 3 lines in 2 files changed: 0 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/28460.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28460/head:pull/28460
PR: https://git.openjdk.org/jdk/pull/28460
More information about the hotspot-jfr-dev
mailing list