Repository navigation
fix(posix): keep a handle on the blob for the copy target - #807
Merged
aduffeck merged 1 commit intoOct 13, 2026
Merged
Conversation
When the upload area and the blobstore are on the same filesystem, Upload renames the source file into the temp file. The block that writes the copy target then opened the source path again, which the rename had removed. So with fs revisions enabled every upload failed, the node kept its processing status and the file answered 425 from then on. Open the temp file before it moves into place instead. The handle stays valid across the rename, so the copy needs neither the source file nor a second lookup of the final path. Installations on two filesystems never saw this, because the EXDEV fallback copies the source and leaves it in place. Fixes opencloud-eu/opencloud#3462
3 of 9 tasks
Author
aduffeck
approved these changes
Oct 13, 2026
Mortimer-RR
added a commit
to Mortimer-RR/reva
that referenced
this pull request
Oct 14, 2026
canUseRenameForUpload was a plain bool. Upload reads it on every call and writes it when a rename fails with EXDEV, so concurrent uploads race on it. Make it an atomic.Bool and read it once per upload. The copy-target part of the original change is dropped: opencloud-eu#807 already fixed it on main. Assisted-by: Claude:claude-opus-5-5
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.
Fixes opencloud-eu/opencloud#3462
Problem
With
STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS=true, every upload with content stays inprocessingand answers 425 to every read, download and delete. It happens when the upload area and the blobstore are on the same device, which is the recommended layout. Affected since reva v2.46.8 (OpenCloud 7.2.4).How to reproduce
STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS=true. Keep the upload area and the spaces on one filesystem.could not finalize upload ... could not open source file '.../uploads/<upload-id>' for reading: ... no such file or directory, and the file returns 425.Cause
Uploadrenamessourceinto the temp file. IfcopyTargetis set, the block after the final rename openssourceagain, and the rename has removed that path. #720 introduced this when it replaced aSeek(0, 0)on the open handle with a newos.Open(source).tree.WriteBlobis the only caller that passes a copy target, and only when fs revisions are on. With the upload area on a second device, the rename fails withEXDEV, the copy fallback keeps the source, and uploads work.Fix
Open the temp file before the rename and copy from that handle. The handle stays valid across the rename, so the copy needs neither the source file nor a second
n.InternalPath(). That second lookup goes through the id cache and returns an empty string if the lookup fails. At that point the blob is already in place, so a failure there would report an error for an upload that worked.Tests
The table in
blobstore_copy_target_test.gouploads with a copy target on the rename path and the copy path, and checks the blob and the copy. The two rename entries fail on main withcould not open source file ... no such file or directoryand pass with this change.go test -race ./pkg/storage/fs/posix/...passes locally and golangci-lint is clean.Files that are already stuck still need the manual repair described in the issue. This change stops new ones.