Repository navigation
Fix files stuck in processing after an interrupted synchronous upload - #976
Conversation
Synchronous uploads no longer mark the node as processing, so an interrupted upload can't leave the file stuck answering 425. See opencloud-eu/opencloud#3240.
Reading such a node now finishes the interrupted upload instead of failing with 425 forever. See opencloud-eu/opencloud#3240.
rhafer
left a comment
There was a problem hiding this comment.
@aduffeck Copilot found a couple for races. I didn't check all of them. The ones I checked look valid to me. some of the appear to be very corner-caseish though. I tried to order them by importance:
- Do not delete a blob after its node has been switched to it — pkg/storage/pkg/decomposedfs/upload/upload.go:261-267
CreateNodeForUpload can return an error after writing the new blob ID: session persistence occurs afterward in store.go:297. If persistence fails, this error path deletes the blob that the node now references, leaving the file unreadable without a processing marker. - Preserve the marker until the replacement metadata is committed — pkg/storage/pkg/decomposedfs/upload/store.go:273-278
When replacing an interrupted upload, a crash or metadata-write error after RemoveXattr but before SetXattrsWithContext leaves the node pointing at the old, possibly missing blob without a processing marker. Subsequent downloads cannot trigger recovery. - Refresh cached attributes after acquiring the recovery lock — pkg/storage/pkg/decomposedfs/upload/recover.go:37-44
Download has already loaded and cached the node attributes before calling recovery, so n.Xattrs() here does not reread them under the lock. During a rolling upgrade, another upload can replace the processing marker while recovery waits; recovery can then act on the old upload and remove the new upload’s marker, exposing a blob that has not finished writing. - Propagate recovered uploads before discarding their sessions — pkg/storage/pkg/decomposedfs/upload/recover.go:83-91
An old synchronous upload interrupted while its marker is present has not reached Propagate. Recovery removes the marker and session without applying its size difference or updating parent tree times. Where tree accounting is enabled, quota usage and directory change detection remain incorrect. - Keep the event’s upload URL readable when publishing — pkg/storage/pkg/decomposedfs/upload/upload.go:257-271
With the filesystem blobstore, WriteBlob normally renames the upload’s binary file into the blobstore. The subsequently published BytesReceived event still contains the session download URL, but GetUpload requires that binary file to exist, so consumers cannot retrieve the content even if they process the event immediately. - Handle a crash between storing the blob and switching the node — pkg/storage/pkg/decomposedfs/upload/upload.go:257-261
If the process stops in this interval, the new blob is unreferenced and has no recovery or cleanup path. On the filesystem blobstore, the upload binary has also been renamed away, so the session cannot be resumed through GetUpload.
Writing the node can report an error after it happened, e.g. when the cache push fails. Sessions finished right away are no longer saved either, so that can't fail the upload after the switch.
Removing it first left a window where the node pointed to the lost blob without the marker that recovery looks for.
Only the tree time, so clients notice the change. The size difference might have been counted already, e.g. by an upload that started while the store was async.
|
@rhafer Thanks, I pushed fixes for all of them except the last two. The invalid upload URL in the event isn't a regression, it shouldn't affect real-worl deployments, and on a sync store there are no consumers for that URL anyway. And with the crash between storing the blob and switching the node the node keeps its old content, so nothing breaks. What's left is just a stale blob and cleaning that up would require some kind of blob garbage collector, not worth it in my opinion. |
|
|
Brings the typed storage results (opencloud-eu#986), the stuck synchronous upload fix (opencloud-eu#976), the main-queue replica fix (opencloud-eu#984), the posix id cache fail fast (opencloud-eu#989) and release 2.52.2 into workpackages. The typed results were mostly mechanical: the ocm received driver keeps its service account client, nextcloud keeps its real TouchFile (now returning a TouchFileResult), and the coordinator ignores the TouchFile result and still reads the node back, because not every driver fills it. opencloud-eu#976 patched the legacy upload session store, which workpackages removed. Its recovery of nodes left processing by an interrupted synchronous upload moves into the pkg fork as Decomposedfs.recoverInterruptedUpload. The coordinator stages sessions in the same <upload dir>/<id> and <id>.info layout as the old store, so nodes stuck by older versions still heal on the first download. Aspects.DisableVersioning stays gone, SeparateBlobs comes along. The sync specs now drive uploads through the coordinator. The two blob-first specs follow with the next commit, which moves the blob-first write to the coordinator path. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The coordinator finished inline uploads in three steps: PrepareUpload pointed the node to the session's blob and marked it as processing, CommitUpload stored the blob, and MarkProcessing removed the mark. A crash in between left the mark forever, since nothing postprocesses synchronous uploads, and downloads failed with 425. This is the coordinator side of the bug opencloud-eu#976 fixed in the legacy upload path on main. We now hand PrepareUpload the staged file (UploadInfo.Source) on the inline path. With a blobstore that keeps blobs apart from the nodes (decomposed, decomposeds3), PrepareUpload stores the blob and only then switches the node, without a mark. For an existing file that happens under the node lock, after the etag and quota checks. For a new file the blob is stored before the node exists, like main does: a crash while writing must not leave a node without metadata that blocks the name. PrepareUpload reports Committed, so the coordinator skips CommitUpload and MarkProcessing. Posix and the other drivers ignore Source and keep the old flow. A mark left by an interrupted upload is cleared in the same write, by emptying it. Only a processing mark counts as an upload superseding the node now, an empty one would make every later upload take a snapshot. The revisions kept only for a rollback go away like after a live commit, but not before the size was propagated: until then the rollback still needs them and their blobs. If the blob cannot be stored, PrepareUpload wraps storage.ErrSourceNotStored and the coordinator keeps the session as failed, like after a failed CommitUpload: the staged bytes are the only copy of the upload and the failure may be transient. If writing the node fails, PrepareUpload puts the old metadata back. The new blob is still kept, because the failed write might have switched the node anyway, so the spec from main now expects the old content plus a leftover blob. Assisted-by: Claude Code:claude-fable-5-2 Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Fix files stuck in processing after an interrupted synchronous upload
Fixes opencloud-eu/opencloud#3240
Synchronous uploads marked the node as processing, pointed it to the new blob and only then stored the blob. If the process died in between, the marker stayed forever, since nothing postprocesses synchronous uploads. Downloads then failed with 425. On the system storage this hits the jsoncs3 share manager files. A space whose file is stuck can't be read or rewritten, so its members can't be listed or changed.
Store the blob first. Synchronous uploads, and 0-byte uploads on async stores, now store the blob before switching the node to it and never set a processing marker. Readers see either the old or the new content. If the switch fails (e.g. etag mismatch), the new blob is deleted. This needs a blobstore that keeps blobs apart from the nodes, so it's behind a new
Aspects.SeparateBlobsflag.NewDefaultsets it, so decomposed and decomposeds3 get it. Posix keeps the old flow.Recover stuck nodes. On synchronous stores,
Downloadfinishes uploads that older versions left behind. Conditions:processing:<id>and its blobid is that<id>.If the bin is still there, the blob is stored from it. The marker is removed only once the blob can be read, and a warning is logged. Other markers are left alone, such as the empty-id marker from the personal data export.
Tested with new Ginkgo specs on the decomposed blobstore with the system storage config. I also tested end to end: a stuck space from the issue, reproduced on 9.0, healed on first read.
Assisted by Claude Opus 5.5