From fe2937eab5f6ebfaef13701af110c36e19e50547 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 17:44:46 -0800 Subject: [PATCH] craft-cloud-local: the README says where a save's etag check holds A Job::Write rechecks the etag under a lock held through the rename, so two saves from one etag cannot both succeed within one process. The README now says so, says that a second process writing the same folder is not covered, and says that two same-length saves on a filesystem with coarse timestamps can leave the same etag. --- crates/cloud-local/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/cloud-local/README.md b/crates/cloud-local/README.md index a5006c2ca3..a2e7cf0ca8 100644 --- a/crates/cloud-local/README.md +++ b/crates/cloud-local/README.md @@ -37,3 +37,16 @@ write never truncates its target in place. It writes a new sibling file and rena over the target, so the target's directory entry is replaced rather than its bytes being overwritten. A rename only ever changes one name; it does not reach through to any other name, inside the root or out, that happens to point at the same inode. + +## Concurrent saves + +A `Job::Write` checks the file's etag again just before the rename, and holds one lock for this +process from that check until the rename is done. Within one process, two saves made from the +same etag cannot both succeed: the second gets `Fault::Conflict`. A second process writing the +same folder does not take that lock, so its save can still land between the check and the rename. +A deployment that needs the guarantee across processes needs a backend whose provider offers a +conditional write. + +The etag is the file's length and modification time. On a filesystem whose timestamps are coarser +than the time between two saves, two saves of the same length can leave the same etag, and the +second save is then not refused.