Skip to content

fix(s3): a lost O_EXCL create drops its copy, so reads find the object that won - #156

Merged
cnuss merged 1 commit into
vfsfrom
fix/excl-loser-drops-copy
Oct 25, 2026
Merged

cnuss merged 1 commit into
vfsfrom
fix/excl-loser-drops-copy

Conversation

@cnuss

@cnuss cnuss commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #155.

When an O_EXCL create's If-None-Match: * upload finds that another instance created the object first, put() still fails the flush with EEXIST. It now also removes the local copy and its entries entry first.

Before this change, on the losing instance:

  • the copy had no synced snapshot, so it was never revalidated, and reads kept returning the loser's own bytes;
  • the stale entry kept exclusive: true, so a later write failed with EEXIST again instead of overwriting the object (If-Match).

Now the next lookup asks S3 and finds the object that won. A later write is an ordinary overwrite of it.

Test: tests/s3.test.ts, "an O_EXCL create that lost drops its copy". It failed before the fix (mine vs theirs) and passes after. The vfs unit suite passes: 271 tests.

Found while reviewing oidc.to's use of writeFile(..., { flag: "wx" }) for single-use claims on an s3 volume.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…t that won

When an exclusive create's conditional PUT finds the object another
instance created first, the flush still fails with EEXIST, and now also
removes the local copy and its entry. Before, the loser kept serving its
own bytes (a copy with no synced snapshot is never revalidated), and a
later write kept the stale exclusive flag and lost again.

Fixes #155

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cnuss
cnuss merged commit 7c82f24 into vfs Oct 25, 2026
28 checks passed
@cnuss
cnuss deleted the fix/excl-loser-drops-copy branch October 25, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant