Skip to content

fix(posix): retry propagating a file's size when propagation fails - #860

Open
butonic wants to merge 1 commit into
opencloud-eu:mainfrom
butonic:fix/posix-treesize-accounting
Open

butonic wants to merge 1 commit into
opencloud-eu:mainfrom
butonic:fix/posix-treesize-accounting

Conversation

@butonic

@butonic butonic commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

A file's size diff was derived from blobsize, which doubled as both the file's
current size and the baseline of what the ancestors already account for. Because
blobsize was written before the propagation was confirmed, a failed propagation
left blobsize at the new size, so the next attempt computed a size diff of 0 and
the size was lost from the ancestors for good (the deficit behind the flaky
"handles deleted files" treesize assertion).

Record the propagated size in a dedicated user.oc.propagatedsize checkpoint and
derive the diff from it instead of blobsize. The checkpoint is advanced only
after a successful propagation (written optimistically with the attributes and
rolled back if the propagation fails), so a retry recomputes the outstanding
delta. The file stays visible throughout, and the sync propagate walk is
unchanged (one ancestor at a time under the already-held file lock).

Delete now subtracts the checkpoint (what the ancestors actually hold) rather
than blobsize, so a file with a pending delta does not over-subtract.

Partial propagation failures (a higher ancestor failing after a lower one
applied) are left to the rescan (scan_fs / WarmupIDCache); making the walk
atomic would re-lock ancestors and add contention under concurrent uploads.

addresses this flakyness:
https://ci.opencloud.rocks/repos/4/pipeline/928/157

• [FAILED] [15.044 seconds]
Watching tree assimilation of files [It] handles deleted files
/go/src/github.com/opencloud-eu/reva/pkg/storage/fs/posix/tree/tree_test.go:193

  [FAILED] Timed out after 15.001s.
  The function passed to Eventually failed at /go/src/github.com/opencloud-eu/reva/pkg/storage/fs/posix/tree/tree_test.go:211 with:
  Expected
      <uint64>: 0
  to equal
      <uint64>: 11
  In [It] at: /go/src/github.com/opencloud-eu/reva/pkg/storage/fs/posix/tree/tree_test.go:212 @ 10/06/26 15:31:30.507

@butonic
butonic requested a review from aduffeck October 7, 2026 08:39
@butonic butonic self-assigned this Oct 7, 2026

@aduffeck aduffeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, but with that change any failure in propagating the change up the tree aborts the assimilation, which means that the file will staying invisible.

Also, what happens when propagation doesn't fail at the parent but the grandparent instead? The parent node already got the size change written to its metadata, so a subsequent assimilation of the file will add it again, no?

It feels like we're only moving the inconsistency risk, not really fixing it.

…-size checkpoint

A file's size diff was derived from blobsize, which doubled as both the file's
current size and the baseline of what the ancestors already account for. Because
blobsize was written before the propagation was confirmed, a failed propagation
left blobsize at the new size, so the next attempt computed a size diff of 0 and
the size was lost from the ancestors for good (the deficit behind the flaky
"handles deleted files" treesize assertion).

Record the propagated size in a dedicated user.oc.propagatedsize checkpoint and
derive the diff from it instead of blobsize. The checkpoint is advanced only
after a successful propagation (written optimistically with the attributes and
rolled back if the propagation fails), so a retry recomputes the outstanding
delta. The file stays visible throughout, and the sync propagate walk is
unchanged (one ancestor at a time under the already-held file lock).

Delete now subtracts the checkpoint (what the ancestors actually hold) rather
than blobsize, so a file with a pending delta does not over-subtract.

Partial propagation failures (a higher ancestor failing after a lower one
applied) are left to the rescan (scan_fs / WarmupIDCache); making the walk
atomic would re-lock ancestors and add contention under concurrent uploads.
@butonic
butonic force-pushed the fix/posix-treesize-accounting branch from 8d7607c to 47b4795 Compare October 7, 2026 15:52
@butonic

butonic commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

true. I chose a different approach that writes an additional property to detect failed propagations on retries.

propagatedsize is a separate attribute, advanced only after a successful propagation. So the write only sets blobsize:

file 10 -> 11, propagation fails:

attempt 1:
    read prev: blobsize=10, propagatedsize=10   -> sizeDiff = 11 - 10 = +1
    SetMultiple(blobsize = 11)                  // only blobsize changes; propagatedsize stays 10
    Propagate(+1) FAILS                          // propagatedsize NOT advanced
    on-disk now: blobsize=11, propagatedsize=10  // divergent = outstanding +1

retry (next scan/event after backoff):
    read prev: blobsize=11, propagatedsize=10   -> sizeDiff = 11 - 10 = +1   // recomputed from disk
    Propagate(+1) OK
    Set(propagatedsize = 11)                     // now they agree

So the retry doesn't need the "old blobsize". It reads the persisted propagatedsize (10) and the persisted blobsize (11), both on disk, and recomputes +1. The old baseline survives precisely because we never wrote it into blobsize's slot; it lives in its own attribute.

@NickWalters

NickWalters commented Oct 11, 2026 •

Copy link
Copy Markdown

I think this can count a size twice. Only assimilation writes propagatedsize, but an API upload and a heal from disk (full warmup) change the ancestors' sizes without it. The next edit on disk then adds the old delta again: a 5-byte file, uploaded as 12 bytes, then edited to 13 bytes, ends with a treesize of 20. Specs and a suggestion are in #853 (comment).

@rhafer rhafer removed the status in OpenCloud Team Board Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants