pkg/storage: report sessions without a node as orphaned - #699
Open
kobergj wants to merge 1 commit into
Open
Conversation
The orphaned upload session filter only matched sessions whose node could not be read. A session whose node does not exist at all was not matched, because ReadNode deliberately swallows a missing node and reports no error. That left an unrecoverable state: when a cleanup removed the orphaned node but did not get as far as removing the session, the remaining session and its upload data became invisible to the filter and could never be cleaned up again. Report a session as orphaned when its node cannot be read or does not exist. Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com>
✅ 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. |
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
Follow-up to #692, which added the orphaned upload session filter. That filter only matches sessions whose node cannot be read:
It does not match a session whose node does not exist at all, because
ReadNodedeliberately swallows a missing node and reports no error:So
err == niland the session is reported as healthy, even though its upload can never finish.That leaves a state which cannot be recovered.
Cleanupremoves the orphaned node before deleting the bin and info files (deliberately — the data must not be destroyed if the revert fails). If it does not get as far as the deletions, the session and its upload payload remain on disk while the node is already gone. The filter then no longer matches them,uploads sessions --cleanhas nothing to act on, and the leftover bytes can never be collected.Found while testing the ownCloud Infinite Scale CLI against a deliberately orphaned upload: after cleaning it once, a second
--orphanedrun reported nothing while the session's.infoand payload were still present inuploads/.Changes
Report a session as orphaned when its node cannot be read or does not exist:
The doc comment now spells out both routes into the state and why the second has to be detected through
Existsrather than through an error.No change was needed in
revertNode: for a missing nodeReadNodereturns no error, soProcessingIDfails, the revert is skipped and it returnsnilwithout propagating a size change a second time.Tests
Adds a test that drives the filter through
ListUploadSessions, the way the CLI uses it: a healthy session is not reported, a session whose node has been removed entirely is reported exactly once, and the negated filter reports nothing. It also asserts the underlying premise — thatReadNodeon a missing node returns no error withExists == false— so the test documents why the check is written this way.Verified that the test fails without the change and passes with it.
🤖 Generated with Claude Code