Versions on s3: a move adds a duplicate version (copy mode: unrecorded files; put/none modes: every file) #943

Closed
opened 2026-10-16 22:12:04 +00:00 by Cordy · 4 comments
Owner

Found in the fix-922 Task 6 re-review (2026-10-17).

What happens

Since #922, a move first records the source file if it has no record, so that a save racing the move cannot lose it.

On s3 the move is a copy followed by a delete. Whether the moved file can still name that record depends on the store's records mode:

  • copy mode: a file with no record (written before #922, or published unrecorded under R3) gets a snapshot that the moved file cannot name. Each move of such a file, including Move to trash and Restore, adds a visible version that holds the current content.
  • put and none modes (stores whose CopyObject drops object metadata): every move of any file adds such a duplicate. For example, after 3 moves the version list reads ["two","two","two","one"].

Nothing is lost; the list just gains duplicate entries.

Proposed fix for copy mode (from the review)

In versions.Rename, when the source has no record:

  1. Call CopyRecorded(old, new, plan). The record lands in the destination's chain, and the destination is published from it, so it carries the record's name.
  2. Delete old.
  3. Merge the chains.

This costs the same requests as today and is identity-safe. It needs:

  • a plan whose Commit does not take the serializer, because the rename already holds both paths;
  • a small optional capability that tells s3 copy mode apart from posix copy mode;
  • a guard for replace support and MaxCopySize.

Put and none modes

Decide whether to re-upload on move (cost) or document the duplicates.

Tests

Twin and sequential rename tests on s3 copy/put/none: N moves must not add N versions.

Found in the fix-922 Task 6 re-review (2026-10-17). ## What happens Since #922, a move first records the source file if it has no record, so that a save racing the move cannot lose it. On s3 the move is a copy followed by a delete. Whether the moved file can still name that record depends on the store's records mode: - **copy mode:** a file with no record (written before #922, or published unrecorded under R3) gets a snapshot that the moved file cannot name. Each move of such a file, including Move to trash and Restore, adds a visible version that holds the current content. - **put and none modes** (stores whose CopyObject drops object metadata): every move of any file adds such a duplicate. For example, after 3 moves the version list reads `["two","two","two","one"]`. Nothing is lost; the list just gains duplicate entries. ## Proposed fix for copy mode (from the review) In `versions.Rename`, when the source has no record: 1. Call `CopyRecorded(old, new, plan)`. The record lands in the destination's chain, and the destination is published from it, so it carries the record's name. 2. Delete `old`. 3. Merge the chains. This costs the same requests as today and is identity-safe. It needs: - a plan whose `Commit` does not take the serializer, because the rename already holds both paths; - a small optional capability that tells s3 copy mode apart from posix copy mode; - a guard for `replace` support and `MaxCopySize`. ## Put and none modes Decide whether to re-upload on move (cost) or document the duplicates. ## Tests Twin and sequential rename tests on s3 copy/put/none: N moves must not add N versions.
Author
Owner

Deep research (2026-10-17)

Full write-up with sources and a store-by-store table: ~/cairn-work/scratch/b7e/backlog/research-943.md.

Findings

  • Metadata on copy. No current store in the survey drops user metadata on CopyObject. The survey covered AWS, MinIO, Ceph RGW, Garage, SeaweedFS, Wasabi, B2, R2, Scaleway, OVH, Hetzner, IONOS, Exoscale and StorageGRID. The known cases are old: SeaweedFS lost metadata until May 2022 (#3047), and Ozone ignored the directive until April 2024. Cairn's metadata is about 110 bytes, far below every limit; the tightest is B2 with encryption at 2,048 bytes. The 2026-10-17 Garage probe confirms Garage keeps metadata on COPY and honours REPLACE. Our dogfood runs in copy mode.
  • How other systems handle it. They either never rename objects, because they keep an index (Nextcloud S3 primary, oCIS, Seafile, JuiceFS), or they trust server-side copy (rclone, s3fs). s3fs calls its re-upload fallback "not recommended".

Options

  • (b) Re-upload on move: rejected. A move would cost 2 to 3 times the file size in traffic. Moving a 20 GiB folder to trash would take about 30 to 60 minutes at 100 Mbit/s upload, with the rename lock held the whole time.
  • (a) REPLACE copy: helps no known store. Every store that fixed COPY fixed REPLACE in the same change.
  • (d) Find the current record by ETag and size when the moved file names none. This mirrors posix copy mode, which already matches on size and mtime.
    • A boot probe checks that ETags survive a copy.
    • It costs no extra bytes, and one LIST instead of one HEAD.
    • It removes the move duplicates in put mode, and the move and save duplicates in none mode.
    • It never risks loss. A miss gives today's duplicate. A false match would need an MD5 collision on content that has no record of its own, which Cairn never publishes.

Recommendation

  • Copy mode (Garage, AWS, MinIO, all current stores): the reviewed CopyRecorded move fix.
  • Put and none modes: (d) plus documenting the duplicates on stores whose ETags change, such as AWS with SSE-KMS or SSE-C.

Side finding

OVH Local Zones do not support CopyObject at all, so Cairn's boot probe would fail there and Cairn would refuse to start. Filing a separate issue.

Decision needed

For put and none modes: (d) identify by ETag and size, plus documenting the rest? Or document only?

## Deep research (2026-10-17) Full write-up with sources and a store-by-store table: `~/cairn-work/scratch/b7e/backlog/research-943.md`. ### Findings - **Metadata on copy.** No current store in the survey drops user metadata on CopyObject. The survey covered AWS, MinIO, Ceph RGW, Garage, SeaweedFS, Wasabi, B2, R2, Scaleway, OVH, Hetzner, IONOS, Exoscale and StorageGRID. The known cases are old: SeaweedFS lost metadata until May 2022 (#3047), and Ozone ignored the directive until April 2024. Cairn's metadata is about 110 bytes, far below every limit; the tightest is B2 with encryption at 2,048 bytes. The 2026-10-17 Garage probe confirms Garage keeps metadata on COPY and honours REPLACE. Our dogfood runs in copy mode. - **How other systems handle it.** They either never rename objects, because they keep an index (Nextcloud S3 primary, oCIS, Seafile, JuiceFS), or they trust server-side copy (rclone, s3fs). s3fs calls its re-upload fallback "not recommended". ### Options - **(b) Re-upload on move: rejected.** A move would cost 2 to 3 times the file size in traffic. Moving a 20 GiB folder to trash would take about 30 to 60 minutes at 100 Mbit/s upload, with the rename lock held the whole time. - **(a) REPLACE copy: helps no known store.** Every store that fixed COPY fixed REPLACE in the same change. - **(d) Find the current record by ETag and size when the moved file names none.** This mirrors posix copy mode, which already matches on size and mtime. - A boot probe checks that ETags survive a copy. - It costs no extra bytes, and one LIST instead of one HEAD. - It removes the move duplicates in put mode, and the move and save duplicates in none mode. - It never risks loss. A miss gives today's duplicate. A false match would need an MD5 collision on content that has no record of its own, which Cairn never publishes. ### Recommendation - **Copy mode (Garage, AWS, MinIO, all current stores):** the reviewed CopyRecorded move fix. - **Put and none modes:** (d) plus documenting the duplicates on stores whose ETags change, such as AWS with SSE-KMS or SSE-C. ### Side finding OVH Local Zones do not support CopyObject at all, so Cairn's boot probe would fail there and Cairn would refuse to start. Filing a separate issue. ### Decision needed For put and none modes: (d) identify by ETag and size, plus documenting the rest? Or document only?
Author
Owner

Decided by Nikola (2026-10-17):

  • Copy mode: the reviewed CopyRecorded move fix.
  • Put and none modes: find the current record by ETag and size, after a boot probe confirms ETags survive a copy. Where they don't (for example AWS with SSE-KMS or SSE-C), document the duplicates that remain.
  • Re-upload on move: rejected.

Implementation: batch 2.

**Decided by Nikola (2026-10-17):** - **Copy mode:** the reviewed CopyRecorded move fix. - **Put and none modes:** find the current record by ETag and size, after a boot probe confirms ETags survive a copy. Where they don't (for example AWS with SSE-KMS or SSE-C), document the duplicates that remain. - **Re-upload on move:** rejected. Implementation: batch 2.
Cordy closed this issue 2026-10-17 20:40:32 +00:00
Author
Owner

Shipped in v0.6.349 (PR #959), and both dogfoods run it.

Copy mode (Garage): a move of a file that has no record is now a recorded move. The file is recorded in the destination's chain, and the moved file names that record, so no duplicate is created.

Put and none modes: Cairn matches by ETag and size. This only applies when the boot probe finds ETags that are the MD5 of the content and that tell different contents apart; the start line then carries etag_match=true.

Old record: it is deleted only when the identity is exact. A move also re-checks its source after reading it, so a save of the source on another instance during the move loses nothing.

The live move check will be done after the next sign-in.

**Shipped in v0.6.349 (PR #959), and both dogfoods run it.** **Copy mode (Garage):** a move of a file that has no record is now a recorded move. The file is recorded in the destination's chain, and the moved file names that record, so no duplicate is created. **Put and none modes:** Cairn matches by ETag and size. This only applies when the boot probe finds ETags that are the MD5 of the content and that tell different contents apart; the start line then carries `etag_match=true`. **Old record:** it is deleted only when the identity is exact. A move also re-checks its source after reading it, so a save of the source on another instance during the move loses nothing. The live move check will be done after the next sign-in.
Author
Owner

Live result (files-bao, Garage copy mode, v0.6.349, 2026-10-18; recorded on PR #959): PASS for copy mode. I moved a file with 2 versions from /home/b12-live/ into /spaces/test and back. It kept exactly its 2 versions and gained no duplicate.

Not seen live: the put and none modes, where a record is matched by ETag and size. No dogfood runs those modes, so they are covered by the boot probe and the rig tests only.

**Live result (files-bao, Garage copy mode, v0.6.349, 2026-10-18; recorded on PR #959): PASS for copy mode.** I moved a file with 2 versions from `/home/b12-live/` into `/spaces/test` and back. It kept exactly its 2 versions and gained no duplicate. **Not seen live:** the put and none modes, where a record is matched by ETag and size. No dogfood runs those modes, so they are covered by the boot probe and the rig tests only.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#943
No description provided.