Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chunkedreader: fix parallel reader hanging forever when a stream fails - #9901

Open
diivfx wants to merge 1 commit into
rclone:masterfrom
diivfx:fix-parallel-stream-error-hang
Open

chunkedreader: fix parallel reader hanging forever when a stream fails#9901
diivfx wants to merge 1 commit into
rclone:masterfrom
diivfx:fix-parallel-stream-error-hang

Conversation

@diivfx

@diivfx diivfx commented Sep 10, 2026

Copy link
Copy Markdown

What does this change do?

Fixes the parallel chunked reader (--vfs-read-chunk-streams > 0) hanging forever when one of its streams fails part way through a chunk. On an S3 mount with --vfs-cache-mode full this showed up as a directory rename that never returned while a file in that directory was being read (details and goroutine dump in #9900).

Two changes in fs/chunkedreader/parallel.go:

  • stream.read now notices when the stream's background read has finished. It drains what was buffered and then returns the error the stream finished with, instead of looping on WaitWrite for data that will never arrive.
  • parallel.Read declared nn, err := inside its loop, so a stream error never reached the return n, err after the loop and the caller got (0, nil) repeatedly. It now assigns to err.

TestParallelStreamErrorDoesNotHang uses an object whose stream fails mid-chunk; it hangs without the change.

Tested with go build, go test -race ./fs/chunkedreader/ -count=3, and make quicktest (178 packages pass; cmd/nfsmount and fs/logger fail identically on unpatched master in this environment, no NFS mount available). On the S3 mount from the issue, the rename-while-reading case now completes and the readers get an error instead of hanging; repeated a few dozen times.

Linked issue

Fixes #9900

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend and if submitting a new backend can provide a test account for the integration tester.
  • This Pull Request is ready for review.

@diivfx
diivfx requested a review from ncw as a code owner September 10, 2026 17:06
When one of the parallel streams failed part way through its chunk -
for example because the object was deleted or replaced under an rclone
mount while it was being read - stream.read never looked at the
stream's error and kept looping on WaitWrite for data that would never
arrive. parallel.Read also declared nn, err := inside its loop, so even
a surfaced stream error was dropped and the caller received (0, nil)
indefinitely.

With --vfs-cache-mode full this left the VFS downloader stuck, and a
rename of a directory containing such a file hung the mount: the
rename waited in Downloaders.Close on the async reader, which waited
in stream.read.

A stream whose background read has finished now drains what it had
buffered and then returns the error it finished with, and
parallel.Read passes that error on to the caller. The new test uses an
object whose stream fails mid-chunk and hangs without this change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@diivfx
diivfx force-pushed the fix-parallel-stream-error-hang branch from 87487dc to 2dbdcb6 Compare September 10, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mount: renaming a directory hangs forever while a file in it is being read (S3, vfs-cache-mode full, vfs-read-chunk-streams > 0)

1 participant