[AMORO-4373] Fix concurrency race condition in RollingFileCleaner causing silent orphan file leaks - #4374
Conversation
…sing orphan file leaks
j1wonpark
left a comment
There was a problem hiding this comment.
Thanks for the PR, but the premise of #4373 does not hold on master. planWith(...) only parallelizes manifest reading; the deleteWith callback runs on a direct executor by default (Iceberg 1.8.1 RemoveSnapshots.java:65), and Amoro never calls executeDeleteWith(...). So addFile runs sequentially on the commit thread. I confirmed this with a 10-thread maintenance pool over ~2.5k expired files: every callback ran on the calling thread.
The "empirical test on unpatched master" in the issue is this PR's own testConcurrentCleanFiles calling addFile from 10 threads directly. Did you actually observe this leak on a real AMS deployment, @aakashofficial-k01?
|
No, I haven't observed this on a live deployment, this came out of an offline code inspection of Seeing Closing this PR and #4373 to avoid unnecessary churn. Thanks for the review and learnings, @j1wonpark. |
Why are the changes needed?
Close #4373.
In
IcebergTableMaintainer.expireSnapshots, table snapshots are planned and expired concurrently usingIcebergThreadPools.getMaintenanceExecutor(). InRollingFileCleaner,doCleanFiles()was unsynchronized and directly operated oncollectedFiles. When worker threads concurrently calledaddFile()while remote bulk deletion was in flight, newly submitted files were added tocollectedFilesand subsequently wiped byfinally { collectedFiles.clear(); }before being deleted, causing silent orphan storage leaks.Brief change log
RollingFileCleaner, replacecollectedFileswithBlockingQueue<String>.doCleanFiles(), synchronize execution and atomically drain pending files into a local batch viacollectedFiles.drainTo(toClean)before deletion.clear().testConcurrentCleanFilesinTestRollingFileCleanerto verify concurrent additions during bulk deletion.How was this patch tested?
Documentation