Fix S3 delete throwing DirectoryNotEmptyException due to eventual consistency#6833
Merged
bentsherman merged 2 commits intomasterfrom Feb 17, 2026
Merged
Fix S3 delete throwing DirectoryNotEmptyException due to eventual consistency#6833bentsherman merged 2 commits intomasterfrom
bentsherman merged 2 commits intomasterfrom
Conversation
…sistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
✅ Deploy Preview for nextflow-docs-staging canceled.
|
bentsherman
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DirectoryNotEmptyExceptioncheck fromS3FileSystemProvider.delete()— S3 directories are virtual (marker objects or implied key prefixes), so enforcing POSIX-like emptiness semantics is unreliable due to eventual consistency and unnecessary because deleting a directory marker does not affect its children.Problem
When
PublishDircopies a directory to S3 and the target already exists, Nextflow's retry logic deletes the existing directory first viaFileHelper.deletePath()→Files.walkFileTree(). The walk deletes all child objects, thenpostVisitDirectorycallsFiles.delete(dir)on the parent.However,
S3FileSystemProvider.delete()lists the directory's children to enforce aDirectoryNotEmptyExceptioncheck. Due to S3 eventual consistency, just-deleted objects may still appear in the listing, causing the check to fail. The exception propagates through Failsafe retry, which eventually hangs — blockingThreadPerTaskExecutor.awaitTermination()on the main thread indefinitely.Observed in production: a pipeline with 2835 succeeded tasks and 1 failed task hung for 35+ minutes waiting for file transfers to complete, with 2
PublishDirvirtual threads stuck trying to copy aquastoutput directory to S3.Fix
Remove the directory emptiness check from
S3FileSystemProvider.delete(). On S3, "directories" are either marker objects (key/) or implied by child key prefixes — there is no real directory to protect. The emptiness check was both unreliable (eventual consistency) and semantically wrong for object storage.Test plan
'should delete a non-empty directory on S3 without throwing'inAwsS3NioTest— confirmed RED (fails before fix), GREEN (passes after fix)🤖 Generated with Claude Code