-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8365066: RecordingStream and RemoteRecordingStream do not terminate when the associated Recording is stopped or closed externally #26710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…hen the associated Recording is stopped or closed externally
👋 Welcome back cito! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Did you look into adding a FlightRecorderListener and implementing recordingStateChanged to check if the RecordingState is CLOSED and then call close() on the stream? Or perhaps it would be better to set a flag and let the thread running the stream close itself after the next flush is complete. For a RemoteRecordingStream there is a JMX notification that can be listened on. |
private static class SendEventListener implements FlightRecorderListener { | ||
@Override | ||
public void recordingStateChanged(Recording recording) { | ||
if(recording.getState() == RecordingState.RUNNING){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recording.getState() == RecordingState.RUNNING){ | |
if (recording.getState() == RecordingState.RUNNING){ |
private static class SendEventListener implements FlightRecorderListener { | ||
@Override | ||
public void recordingStateChanged(Recording recording) { | ||
if(recording.getState() == RecordingState.RUNNING){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recording.getState() == RecordingState.RUNNING){ | |
if (recording.getState() == RecordingState.RUNNING){ |
@@ -469,7 +467,9 @@ public void close() { | |||
ManagementSupport.setOnChunkCompleteHandler(stream, null); | |||
stream.close(); | |||
try { | |||
mbean.closeRecording(recordingId); | |||
if(eventSource.getState() != RecordingState.CLOSED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(eventSource.getState() != RecordingState.CLOSED) { | |
if (eventSource.getState() != RecordingState.CLOSED) { |
} | ||
|
||
@Override | ||
public RecordingState getState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public RecordingState getState() { | |
public RecordingState getState() { | |
@@ -169,6 +167,19 @@ protected void processRecursionSafe() throws IOException { | |||
"ns (epoch), parser at " + lastFlush + "ns (epoch)."); | |||
return; | |||
} | |||
|
|||
if(!barrier.used()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(!barrier.used()) { | |
if (!barrier.used()) { |
if (isRecordingStream()) { | ||
if (recording.getState() == RecordingState.STOPPED && !barrier.used()) { | ||
logStreamEnd("recording stopped externally."); | ||
if(!barrier.used()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(!barrier.used()) { | |
if (!barrier.used()) { |
if (state == RecordingState.CLOSED){ | ||
logStreamEnd("Event source is closed externally"); | ||
return; | ||
}else if(state == RecordingState.STOPPED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}else if(state == RecordingState.STOPPED) { | |
} else if (state == RecordingState.STOPPED) { |
private static class SendEventListener implements FlightRecorderListener{ | ||
@Override | ||
public void recordingStateChanged(Recording recording) { | ||
if(recording.getState() == RecordingState.RUNNING){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recording.getState() == RecordingState.RUNNING){ | |
if (recording.getState() == RecordingState.RUNNING){ |
private static class SendEventListener implements FlightRecorderListener { | ||
@Override | ||
public void recordingStateChanged(Recording recording) { | ||
if(recording.getState() == RecordingState.RUNNING){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recording.getState() == RecordingState.RUNNING){ | |
if (recording.getState() == RecordingState.RUNNING){ |
@@ -40,21 +41,44 @@ | |||
*/ | |||
public class TestStoppedRecording { | |||
|
|||
private static class SendEventListener implements FlightRecorderListener{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static class SendEventListener implements FlightRecorderListener{ | |
private static class SendEventListener implements FlightRecorderListener { |
@Override | ||
public long getStopTime() { | ||
Optional<RecordingInfo> recordingInfo = mbean.getRecordings().stream().filter(r -> r.getId() == recordingId).findFirst(); | ||
if(recordingInfo.isEmpty()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recordingInfo.isEmpty()){ | |
if (recordingInfo.isEmpty()){ |
} | ||
|
||
@Override | ||
public RecordingState getState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public RecordingState getState() { | |
public RecordingState getState() { | |
@Override | ||
public RecordingState getState() { | ||
Optional<RecordingInfo> recordingInfo = mbean.getRecordings().stream().filter(r -> r.getId() == recordingId).findFirst(); | ||
if(recordingInfo.isEmpty()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recordingInfo.isEmpty()){ | |
if (recordingInfo.isEmpty()){ | |
public RecordingState getState() { | ||
Optional<RecordingInfo> recordingInfo = mbean.getRecordings().stream().filter(r -> r.getId() == recordingId).findFirst(); | ||
if(recordingInfo.isEmpty()){ | ||
return RecordingState.CLOSED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return RecordingState.CLOSED; | |
return RecordingState.CLOSED; | |
@egahlin That sounds like a good idea. I’ll give it a try. |
Fix an issue where RecordingStream and RemoteRecordingStream do not stop when their underlying the local/remote recording stop.
Introduce an internal EventSource abstraction to unify control across local (PlatformRecording) and remote (FlightRecorderMXBean) recordings, ensuring consistent propagation of stop/close and stop time to the consumer streams.
Tests updated to validate lifecycle consistency:
Verifies that stopping/closing the underlying recording (local and remote) properly stops/closes the corresponding stream.
Test: jdk/jdk/jfr
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26710/head:pull/26710
$ git checkout pull/26710
Update a local copy of the PR:
$ git checkout pull/26710
$ git pull https://git.openjdk.org/jdk.git pull/26710/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26710
View PR using the GUI difftool:
$ git pr show -t 26710
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26710.diff