Skip to content

fix(decomposedfs): release the quota of orphaned upload sessions - #951

Merged
butonic merged 3 commits into
workpackagesfrom
port-692
Nov 3, 2026
Merged

butonic merged 3 commits into
workpackagesfrom
port-692

Conversation

@butonic

@butonic butonic commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Before the coordinator takes over: an upload session whose node metadata can no longer be read kept its optimistically propagated size forever, so the space quota never came back.

We now have an Orphaned filter on storage.UploadSessionFilter, evaluated last in ListUploadSessions because it reads the node metadata of every session. Cleaning up an orphaned session reverts the size propagation from the ids stored in the session and removes the node, but only a node the upload created. The node is reverted before the bin and info files are removed, so a failure leaves a session that can be retried instead of a lost one. PostprocessingFinished now cleans up orphaned sessions instead of leaving them to be retried forever.

Review focus:

  • upload/upload.go revertNode in both copies: the "only remove a node the upload created" check, and that the quota is released exactly once
  • IsOrphaned: what counts as orphaned (exists, but metadata unreadable) vs. simply gone

Replaces #896 (fork branch, GitHub stacks need all branches in this repository). The reviews are over there.

Assisted by Claude Code (claude-opus-5-5): it adapted the changes, split them into this stack and wrote this description.

@butonic butonic added the Type:Maintenance E.g. technical debt, packaging, etc. label Oct 29, 2026
@butonic
butonic added this pull request to stack #952 October 29, 2026 14:19
Base automatically changed from merge-main-into-workpackages to workpackages October 30, 2026 10:14
Port of owncloud#692, adapted to our diverged decomposedfs copies:

- Add an Orphaned upload session filter to storage.UploadSessionFilter,
  evaluated last in ListUploadSessions of both copies because it reads
  the node metadata of every session.
- Add IsOrphaned and syntheticNode to OcisSession and DecomposedFsSession.
- Extract the node reverting from upload.Cleanup into revertNode and run
  it before the bin and info files are removed, so a failure leaves a
  recoverable session instead of a deleted one. The readable-node branch
  keeps our local RevertUpload/Purge logic (upstream has
  RevertCurrentRevision). When the node metadata is unreadable, revert
  the optimistic size propagation from a node built out of the session's
  SpaceID/NodeID/NodeParentID and remove the orphaned node, so the space
  quota is released; the upload is kept when the quota cannot be
  released. In the pkg fork the orphaned node is removed via lu.PurgeNode
  and its metadata via the MetadataNode-based backend Purge.
- Clean up orphaned sessions on PostprocessingFinished instead of
  returning early and leaving them to be retried forever.
- Add the regression test to both upload_async_test.go copies.

Changelog is maintained in the ready-release-go PR, not per commit.

Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
- Add node.ErrMissingParentID and treat a session as orphaned only when
  reading its node fails with it. Other read errors, e.g. an unavailable
  cache, are logged and leave the session untouched.
- On PostprocessingFinished, only drop the bytes and info of an orphaned
  session when postprocessing asked to delete the upload.
- Clear and persist the session's sizeDiff before reverting it, so a
  repeated cleanup does not release the quota twice.
- Remove the bytes even if reverting the node failed, so infected files
  do not stay on disk. Only the info is kept for a retry.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Cleaning up an orphaned upload removed the node without checking
whether the upload created it. For an upload that overwrites a file
the node holds the previous version, on posix the user's file itself,
so it got deleted. We now only revert the size diff for an existing
node.

A node the upload created is removed only while it is still empty: the
uploaded bytes only get there when the upload is finalized. If it has
content, something outside of us wrote it, e.g. an editor saving
atomically on posix before the watcher assimilated the file, so we keep
it.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
@butonic butonic changed the title pkg/storage: release quota of orphaned upload sessions fix(decomposedfs): release the quota of orphaned upload sessions Nov 3, 2026
@butonic
butonic merged commit 122b9f8 into workpackages Nov 3, 2026
19 checks passed
@butonic
butonic deleted the port-692 branch November 3, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type:Maintenance E.g. technical debt, packaging, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants