Skip to content
This repository was archived by the owner on Sep 14, 2025. It is now read-only.

Conversation

@vlovich
Copy link

@vlovich vlovich commented Jan 3, 2022

Gracefully handle multiple threads deleting an object at the same time.
When two concurrent requests come in to delete the last two remaining
objects in a given path, they'll be racing each other trying to delete
and cause a spurious deletion failure for one of them.

Fixes #788

Copy link
Collaborator

@leontastic leontastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vlovich Thank you for your PR contribution.

I read the issue you filed and agree with your reasoning on the solution. I think you're missing a parts.pop() call, see my comment in my review.

Give it a test and let me know. I haven't touched npm in years but I can probably publish a release for this bugfix after it's merged.

!readdirSync(path.join(bucketPath, ...parts)).length
) {
await fs.rmdir(path.join(bucketPath, ...parts));
parts.pop();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to re-add this line. Otherwise empty parent directories don't get cleaned up. You actually included it in your example here: #788 (comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed reply. I hadn't seen this. Good catch. I left the pop in there locally but somehow corrupted the patch when applying.

Gracefully handle multiple threads deleting an object at the same time.
When two concurrent requests come in to delete the last two remaining
objects in a given path, they'll be racing each other trying to delete
and cause a spurious deletion failure for one of them.

Fixes jamhall#788
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apparent race condition deleting objects results in ENOENT

2 participants