Integrated: 8370715: JFR: Races are possible when dumping recordings
Robert Toyonaga
duke at openjdk.org
Thu Dec 4 13:59:52 UTC 2025
On Fri, 21 Nov 2025 21:02:56 GMT, Robert Toyonaga <duke at openjdk.org> wrote:
> #### 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
This pull request has now been integrated.
Changeset: c4ec983d
Author: Robert Toyonaga <rtoyonag at redhat.com>
Committer: Thomas Stuefe <stuefe at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/c4ec983da57ee8aea71e88d5de2570c5d65a69df
Stats: 88 lines in 2 files changed: 87 ins; 0 del; 1 mod
8370715: JFR: Races are possible when dumping recordings
Reviewed-by: egahlin, stuefe
-------------
PR: https://git.openjdk.org/jdk/pull/28460
More information about the hotspot-jfr-dev
mailing list