Fix async profiler output copy to s3 [skip ci]#14723
Fix async profiler output copy to s3 [skip ci]#14723jihoonson wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Signed-off-by: Jihoon Son <ghoonson@gmail.com>
b4334a4 to
af157d1
Compare
Greptile SummaryThis PR fixes async profiler output not being saved to S3 by replacing Confidence Score: 5/5Safe to merge — targeted fix with correct resource management. All three copy sites are updated consistently. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Exec as Executor
participant FS as Hadoop FileSystem
participant S3 as S3 / HDFS
Exec->>FS: fs.create(outPath, overwrite=false)
FS-->>Exec: OutputStream (out)
Exec->>Exec: Files.copy(localPath, out)
Note over Exec,FS: withResource ensures out.close() on both success and exception
Exec->>FS: out.close() [via withResource]
FS->>S3: Finalize / commit object
S3-->>FS: OK
Exec->>Exec: localFile.delete()
Reviews (3): Last reviewed commit: "fix line limit" | Re-trigger Greptile |
| if (compressJfrFile(tempFilePath, compressedTempPath)) { | ||
| fs.copyFromLocalFile(new Path(compressedTempPath.toString), outPath) | ||
| withResource(fs.create(outPath, false)) { out => | ||
| Files.copy(compressedTempPath, out) | ||
| } | ||
| compressedTempPath.toFile.delete() // delete compressed temp file |
There was a problem hiding this comment.
Compressed temp file not deleted on exception
If Files.copy(compressedTempPath, out) throws, withResource correctly closes out, but the compressedTempPath.toFile.delete() on line 361 is skipped, leaking the compressed temp file. The same exception also skips the tempFilePath.toFile.delete() at line 374. A try/finally (or a second withResource-like guard) around compressedTempPath would ensure cleanup on both normal and exceptional paths.
There was a problem hiding this comment.
@greptile-apps this is an existing issue, isn't it? Even before this change, compressedTempPath will be never deleted if fs.copyFromLocalFile throws.
There was a problem hiding this comment.
You're right, that's a pre-existing issue that this PR didn't introduce. My comment was unfair to flag as part of this review since the change doesn't make the cleanup situation any worse than before. Thanks for the correction.
Tip: You can give me more context with [.greptile/rules.md](https://www.greptile.com/docs/code-review/custom-standards) so I get this right next time.
|
build |
Description
The async profiler currently fails to save its output to s3. This is because it calls
copyFromLocalFileto copy each result file to s3, which has a known issue. This PR usesFiles.copyafter opening a stream to work around the issue.Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance