Repository navigation
pkg/storage: release quota of orphaned upload sessions - #692
Merged
mklos-kw merged 1 commit intoAug 6, 2026
Merged
Conversation
When an upload's target node lost its metadata, e.g. because an ancestor was trashed while the upload was in flight, the node file remained without a readable .mpk. Reading it fails with "Missing parent ID on node", so the upload never finished postprocessing: it stayed in "Processing", could not be downloaded or deleted, and kept consuming the quota. Cleanup made this worse. It removed the upload bytes and the session info file before attempting to revert the node, then bailed out on the failing node read without releasing the quota - destroying both the only copy of the data and the parent id needed to repair the node, while freeing nothing. Revert the node before anything irreversible and fall back to the parent id recorded in the session when the node cannot be read, so the quota is released and the orphaned node removed. Keep the upload if the quota cannot be released. Also clean up such sessions when postprocessing finishes instead of returning early and leaving them to be retried forever. Add an Orphaned upload session filter to list affected sessions. It is only evaluated when set, as it reads the node metadata of every session. Signed-off-by: Julian Koberg <[email protected]>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
kobergj
force-pushed
the
fix/ocisdev-1177-orphaned-upload-sessions
branch
from
August 6, 2026 07:41
fe3d6f3 to
841de45
Compare
mzner
approved these changes
Aug 6, 2026
deyankiteworks
approved these changes
Aug 6, 2026
This was referenced Aug 6, 2026
mklos-kw
added a commit
that referenced
this pull request
Sep 10, 2026
When an upload's target node lost its metadata, e.g. because an ancestor was trashed while the upload was in flight, the node file remained without a readable .mpk. Reading it fails with "Missing parent ID on node", so the upload never finished postprocessing: it stayed in "Processing", could not be downloaded or deleted, and kept consuming the quota. Cleanup made this worse. It removed the upload bytes and the session info file before attempting to revert the node, then bailed out on the failing node read without releasing the quota - destroying both the only copy of the data and the parent id needed to repair the node, while freeing nothing. Revert the node before anything irreversible and fall back to the parent id recorded in the session when the node cannot be read, so the quota is released and the orphaned node removed. Keep the upload if the quota cannot be released. Also clean up such sessions when postprocessing finishes instead of returning early and leaving them to be retried forever. Add an Orphaned upload session filter to list affected sessions. It is only evaluated when set, as it reads the node metadata of every session. Signed-off-by: Julian Koberg <[email protected]> Co-authored-by: kobergj <[email protected]>
butonic
added a commit
to butonic/reva
that referenced
this pull request
Oct 29, 2026
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]>
dragonchaser
pushed a commit
to dragonchaser/reva
that referenced
this pull request
Nov 4, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When an upload's target node loses its metadata — for example because an ancestor directory is moved to the trash while the upload is still in flight — the node file stays on disk without a readable
.mpk. Reading such a node fails withinternal error: Missing parent ID on node, so the upload can never finish postprocessing:ProcessingforeverThe error surfaces at
node/node.go:398. It is reachable becauseloadAttributesreturns empty attributes rather than ENOENT when the.mpkis gone but the node file remains, so the node reportsExists = truewith every attribute blank andParentID == ""is simply the first field checked.Cleaning these sessions up did not work either, and made things worse:
Cleanupremoved the upload bytes and the session.infofile first, then attempted to revert the node and bailed out on the failing read — never reaching the quota release.uploads/<id>is all there is) and theNodeParentIdrecorded in the.infofile, which is the only remaining information needed to repair the node.PostprocessingFinishedreturned early on the unreadable node beforeCleanupwas called at all, leaving the session behind to be retried indefinitely.Net effect: running a cleanup on an affected session converted a recoverable state into unrecoverable data loss while freeing nothing.
Changes
Cleanupnow reverts the node before removing the bin and info files, so a failure leaves a recoverable session instead of a deleted one.SpaceID/NodeID/NodeParentID, and the orphaned node file plus its metadata are removed. Propagation only needs the parent id, which the session still has.PostprocessingFinishedinstead of returning early and leaving them to be retried forever.Orphanedupload session filter to list affected sessions. It is only evaluated when set, since it reads the node metadata of every session — default listings are unchanged.Behaviour for readable nodes is unchanged.
Tests
Adds a regression test covering an upload whose node metadata has become unreadable: it asserts the orphaned node is removed, the bytes are cleaned up, and — the actual point — that the quota is released.
The test purges the metadata through the backend rather than unlinking the
.mpkdirectly, otherwise the cached attributes keep the node readable and the test passes even without the fix. Verified that it fails without these changes and passes with them.Notes
make lintcould not be run locally: the pinned golangci-lint (v1.61.0, built with Go 1.23) refuses the repository's Go 1.26 target. This is pre-existing and unrelated to this change;gofmtandgo vetare clean.🤖 Generated with Claude Code