Skip to content

ReadAheadManager.Stop has no production caller; the unmount path relies on context cancellation alone #376

Closed

Description

@scttfrdmn

ReadAheadManager.Stop (internal/fuse/optimizations.go) is exported, sync.Once-guarded, and documented "safe to call multiple times (#104)". Its only callers are in read_path_test.go and readahead_lifetime_test.go. Not MountManager.Unmount, not Adapter.Stop, not anything on the unmount path.

Before the fix in #179 that meant a real leak: five goroutines per NewFileSystem at the default ConcurrentReads: 4, measured 2 → 27 after five constructions, each holding its FileSystem — and through it the backend and cache — reachable for the life of the process.

That leak is fixed, and deliberately not by adding a Stop call. NewReadAheadManager takes the mount's context and both workers select on mount.Done(), so the cancelMount() the adapter already performs is what ends them — no new obligation for a future caller to remember, which is exactly the obligation that was already being missed.

What remains is a smaller, non-urgent inconsistency: an exported lifecycle method that production never calls. Two defensible resolutions, and this issue is to pick one rather than leave both open:

  1. Call it on the unmount path and keep cancellation as the backstop. Belt and braces, at the cost of the same "someone must remember" property on any future mount path.
  2. Unexport or document it as test-only. Cancellation is the production mechanism; stopCh exists so a test can stop a manager whose context it does not own.

Leaning to (2), since (1) reintroduces the coupling the fix removed — but either is fine as long as the code says which one it is. Today a reader finds an exported Stop, reasonably assumes the unmount path calls it, and is wrong.

Not a correctness bug as of #179. Filed so the dead-in-production method does not sit unexplained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fusepriority: lowtype: technical-debt

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions