Skip to content

Comments

Fix S3 delete throwing DirectoryNotEmptyException due to eventual consistency#6833

Merged
bentsherman merged 2 commits intomasterfrom
fix/s3-delete-dir-not-empty
Feb 17, 2026
Merged

Fix S3 delete throwing DirectoryNotEmptyException due to eventual consistency#6833
bentsherman merged 2 commits intomasterfrom
fix/s3-delete-dir-not-empty

Conversation

@pditommaso
Copy link
Member

Summary

  • Remove the DirectoryNotEmptyException check from S3FileSystemProvider.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 PublishDir copies a directory to S3 and the target already exists, Nextflow's retry logic deletes the existing directory first via FileHelper.deletePath()Files.walkFileTree(). The walk deletes all child objects, then postVisitDirectory calls Files.delete(dir) on the parent.

However, S3FileSystemProvider.delete() lists the directory's children to enforce a DirectoryNotEmptyException check. 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 — blocking ThreadPerTaskExecutor.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 PublishDir virtual threads stuck trying to copy a quast output 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

  • Added integration test 'should delete a non-empty directory on S3 without throwing' in AwsS3NioTest — confirmed RED (fails before fix), GREEN (passes after fix)

🤖 Generated with Claude Code

…sistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
@netlify
Copy link

netlify bot commented Feb 13, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 6b9c45f
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6994798d823a3d0008c0395e

@bentsherman bentsherman merged commit f3ac497 into master Feb 17, 2026
24 checks passed
@bentsherman bentsherman deleted the fix/s3-delete-dir-not-empty branch February 17, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants