From 1495f7addbaab5ed6bfb582a63f8cc2f0c97a100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Wed, 15 Jan 2025 16:42:31 +0000 Subject: [PATCH] 8345493: JFR: JVM.flush hangs intermittently Reviewed-by: egahlin Backport-of: 4257215a9fa02f74ccd4fc62893d4b1a232a8754 --- .../share/classes/jdk/jfr/internal/PlatformRecorder.java | 4 ++++ .../share/classes/jdk/jfr/internal/periodic/FlushTask.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index b33a8943042..bb2c8207cfe 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -679,4 +679,8 @@ public synchronized void migrate(SafePath repo) throws IOException { public RepositoryChunk getCurrentChunk() { return currentChunk; } + + public synchronized void flush() { + MetadataRepository.getInstance().flush(); + } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java index 407bdadad43..739f32bf634 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ import jdk.jfr.internal.JVM; import jdk.jfr.internal.MetadataRepository; +import jdk.jfr.internal.PlatformRecorder; +import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.util.Utils; /** @@ -44,7 +46,8 @@ public FlushTask() { @Override public void execute(long timestamp, PeriodicType periodicType) { - MetadataRepository.getInstance().flush(); + PlatformRecorder recorder = PrivateAccess.getInstance().getPlatformRecorder(); + recorder.flush(); Utils.notifyFlush(); }