Repository navigation
refactor(fuse): delete ReadAheadManager.Stop and its channel (#376) - #382
Merged
Merged
Conversation
The mount context is the only shutdown signal now. Cancel it and the prefetch workers and the cleanup ticker return; there is nothing else to call. #179 fixed the leak — five goroutines per mount surviving every unmount, each keeping its FileSystem and through it the backend and the cache reachable — by making the mount context a second stop signal, so the `cancelMount()` the adapter already performs is what ends them. What was left over was an exported lifecycle method that nothing outside tests called: not MountManager.Unmount, not Adapter.Stop, not anything on the unmount path. That is the worst of the available states, because a reader finds it and reasonably assumes Unmount calls it. Calling it from Unmount was the other option and is rejected: it reintroduces exactly the "someone must remember this on every mount path" obligation whose being missed was the leak. The issue proposed unexporting it and keeping it for tests, and a mutation refuted that premise. The stated justification was that stopCh expresses the one thing cancellation cannot — stopping a manager whose context the caller does not own. Plausible, and false: neutering the channel's select arm broke no test, so no test needed it either. A second shutdown path with no caller on *either* side is not a seam worth preserving. Two ways to stop the same goroutines is how they came to be stopped by neither. The tests that wanted the workers out of the way now cancel a mount context of their own, via readPathFixture.stopReadAhead, so the test shutdown and the production one are the same code path — which the deleted Stop never was. The ten `defer ram.stop()` calls in optimizations_test.go were pure redundancy against t.Context() and are gone. That helper's doc comment says what a mutation showed it is worth rather than what it looks like it is worth: removing all three calls leaves the suite green over twelve runs, because each caller invokes it during setup before any sequential pattern exists and then replaces or nils the manager, which is the assignment that actually stops new prefetches. It is kept for stopping what it replaces and for exercising the real shutdown path, not for preventing a race it does not currently prevent. Mutation-verified: removing the `mount.Done()` arm from both workers fails TestReadAhead_MountCancellationStopsTheWorkers with "25 read-ahead goroutines still running after every mount context was canceled". Not a behaviour change. internal/fuse has no importer outside this repository and the method had no caller inside it. internal/fuse coverage 68.5% against its floor of 67.
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.
Closes #376.
The mount context is the only shutdown signal now.
ReadAheadManager.Stop, itsstopCh, and itssync.Onceare deleted.What #376 asked
#179 fixed the real leak — five goroutines per mount surviving every unmount, each keeping its
FileSystemand through it the backend and the cache reachable — by making the mount context a stopsignal, so the
cancelMount()the adapter already performs is what ends them. What was left over wasan exported lifecycle method that nothing outside tests called. #376 named two defensible resolutions
and asked for one to be picked:
Unmount, keeping cancellation as a backstop.(1) is rejected for the reason the issue gives: it reintroduces exactly the "someone must remember to
call this on every mount path" obligation whose being missed was the leak.
Why (2) became a deletion
The issue's case for keeping it was that
stopChexpresses the one thing cancellation cannot —stopping a manager whose context the caller does not own, "which is a test's situation and nothing
else's."
Plausible, and false. Neutering the channel's select arm broke no test:
So no test needed it either. A second shutdown path with no caller on either side is not a seam
worth preserving — two ways to stop the same goroutines is how they came to be stopped by neither.
The tests that wanted the workers out of the way now cancel a mount context of their own, through
readPathFixture.stopReadAhead, so the test shutdown and the production one are the same code path.The deleted
Stopnever was. The tendefer ram.stop()calls inoptimizations_test.gowere pureredundancy against
t.Context()and are gone.The helper's comment says what a mutation showed it is worth
Removing all three
stopReadAhead()calls leaves the suite green over twelve runs, and the commentsays so. Each caller invokes it during setup, before any read has established a sequential pattern,
and then nils or replaces the manager — and that assignment is what stops new prefetches from being
scheduled. It is kept for stopping what it replaces and for exercising the real shutdown path, not
for preventing a race it does not currently prevent. Claiming otherwise is how a comment becomes the
next reader's wrong premise, which is the shape of the defect this PR is closing.
Verification
go build ./...,go vet ./...,make lint— 0 issuesgo test -race -count=1 ./...— pass;./internal/fuse/ -count=3— passinternal/fuse 68.5%against a floor of 67mount.Done()arm from both workers failsTestReadAhead_MountCancellationStopsTheWorkerswith "25 read-ahead goroutines still running afterevery mount context was canceled"
Not a behaviour change.
internal/fusehas no importer outside this repository and the method had nocaller inside it.