When JFR Core deletes a JFR recording file, immediately after it tries to delete the temp directory that contained the file which fails and causes a java.nio.file.FileSystemException to be logged.
In the case where JFR is bundled into the APM Java agent, the problem is that all of these exceptions get logged to the Java agent log which can cause the log to grow quite substantially.
Does it make sense to even try to delete the temp directory? Or can this logic simply be removed? In the case where JFR is bundled into the APM Java agent the temp directory contains temp files required by the Java agent that shouldn't be deleted. Perhaps deleting the temp directory only makes sense when JFR is run as a standalone process?
2023-10-24T11:34:48,237-0700 [20374 253] com.newrelic FINEST: Attempting to delete file/path: /var/folders/tm/h6fw9m9x7f18l01c0l7v0m240000gn/T/local-recording2429830726551601231.jfr
2023-10-24T11:34:48,237-0700 [20374 253] com.newrelic FINEST: Attempting to delete file/path: /var/folders/tm/h6fw9m9x7f18l01c0l7v0m240000gn/T
2023-10-24T11:34:48,238-0700 [20374 253] com.newrelic ERROR: Exception occurred attempting to delete file:
java.nio.file.FileSystemException: /var/folders/tm/h6fw9m9x7f18l01c0l7v0m240000gn/T: Operation not permitted
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:100) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106) ~[?:?]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:248) ~[?:?]
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105) ~[?:?]
at java.nio.file.Files.delete(Files.java:1152) ~[?:?]
at com.newrelic.jfr.daemon.JFRUploader.deleteFile(JFRUploader.java:120) ~[newrelic.jar:8.7.0-SNAPSHOT]
at com.newrelic.jfr.daemon.JFRUploader.handleFile(JFRUploader.java:48) ~[newrelic.jar:8.7.0-SNAPSHOT]
at com.newrelic.jfr.daemon.JfrController.lambda$loop$1(JfrController.java:65) ~[newrelic.jar:8.7.0-SNAPSHOT]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
2023-10-24T11:34:48,238-0700 [20374 253] com.newrelic ERROR: Target file permissions: r: true, w: true, x: true
When JFR Core deletes a JFR recording file, immediately after it tries to delete the temp directory that contained the file which fails and causes a
java.nio.file.FileSystemException
to be logged.This is caused by the call to
deleteFile(dumpFile.getParent())
: https://github.com/newrelic/newrelic-jfr-core/blob/87addfa598c6779a86eee7cd1c40991d82e24bab/jfr-daemon/src/main/java/com/newrelic/jfr/daemon/JFRUploader.java#L48In the case where JFR is bundled into the APM Java agent, the problem is that all of these exceptions get logged to the Java agent log which can cause the log to grow quite substantially.
Does it make sense to even try to delete the temp directory? Or can this logic simply be removed? In the case where JFR is bundled into the APM Java agent the temp directory contains temp files required by the Java agent that shouldn't be deleted. Perhaps deleting the temp directory only makes sense when JFR is run as a standalone process?