Repository navigation
fix(coverage): stop internal/fuse's floor flaking on runner load (#438) - #527
Merged
Merged
Conversation
The coverage gate failed PR #426 — a cargoship bump that internal/fuse does not import — at 71.8% against a floor of 72, and a rerun of the same commit passed at 72.5%. That is a 0.5-point margin being decided by how loaded the runner was. Both profiles are still on the run. Downloading them and diffing the uncovered block sets names the difference exactly: eight statements, all of them one arm, and nothing else in the package moved. filesystem.go:1149-1155 fetch serving a follower from a GET in flight filesystem.go:183-189 inflightFetch.slice, reachable only from there filesystem.go:1292-1294 coveringLocked's returning branch A follower only exists when a second read for a contained range arrives while the first GET is still outstanding. An idle machine arranges that by accident; a loaded runner finishes the first GET before the second read starts, `join` returns nil, and all eight statements go unexecuted. So the arm was covered by luck, and #438 is what luck looks like when it runs out. Five tests now own it, and they construct the leader rather than racing for one: registered through start, given its result directly, done closed without going through finish. That is the state a real follower observes, since finish removes a fetch from the map before closing done. Running the new tests alone covers all eight statements, plus six that no run had ever executed: slice's short-leader rejection, three statements of the double-check window between join and start, and fetch's error return. Darwin goes 823/1140 to 829/1140. Six mutations, each caught: slice drops the negative-start check the slice table slice checks claimed length, not held the short-leader test join never finds a leader the join table fetch ignores the leader's error the failed-leader test coveringLocked never matches three tests, incl. two existing fetch returns before retiring the flight the error test Two of those changed the tests. `join` returning nil is invisible to any GET-count assertion, because fetch falls through to start and start's own coveringLocked finds the same leader — so join is an optimization and needed owning directly rather than through fetch. And the failed-leader test passed with or without the `leader.err == nil` check, because fetchUncached returns nil data on failure and slice rejects the leader on length alone; the leader there now holds bytes it must not hand over, which is what makes the branch load-bearing. The error test also uses Fatal rather than Error on the still-advertised check. Continuing past it joins a flight whose done channel nothing closes, which turned that mutation from a 0.05s failure into a ten-minute package timeout naming a goroutine instead of a cause. The floor stays at 72. Ratcheting to the new measurement would spend the margin this work exists to create. Two corrections to .coverage-floors while in there, both measured. The darwin/linux gap is not a denominator difference — coverage counts statements, and unmount_path_linux.go and unmount_path_darwin.go contribute 2 each, so both platforms total 1140; the gap is seven blocks in mount.go and xattr.go. The denominator does move with the toolchain, which is larger and was not known: Go 1.26.6 counts 1140 statements where Go 1.27.1 counts 1790, splitting blocks more finely. A GOTOOLCHAIN=auto machine with a newer Go than go.mod's gets the finer granularity silently, so a local floor check has to pin the toolchain — and every floor in that file shifts when CI's Go moves to 1.27.
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 #438.
What was flaking, exactly
#438 asks for the difference between a 72.5% run and a 71.8% one to be named. Both profiles are
still on the run —
coverageuploadscoverage.outwithif: always(), and run31767088547oncommit
ff795af9has two artifacts, attempt 1 at 03:40 and attempt 2 at 04:31. Downloading bothreproduces the issue's numbers exactly:
Diffing the uncovered block sets gives six blocks, eight statements, strictly one-directional —
attempt 1's covered set is a subset of attempt 2's. Nothing else in the package moved:
All eight are the flight-sharing follower path. A follower only exists when a second read for a
contained range arrives while the first GET is still outstanding — which an idle machine arranges by
accident and a loaded runner does not, because the first GET completes before the second read starts,
joinreturns nil, and the arm never executes. The arm was covered by luck. #438 is what luck lookslike when it runs out, and the cost was a required check going red on a bump that does not import the
package.
The fix
Five tests own the arm now, and they construct the leader instead of racing for one: registered
through
start, given its result directly,doneclosed without going throughfinish. That is thestate a real follower observes —
finishremoves a fetch from the map before it closesdone, so aleader that is both joinable and complete is exactly the window a follower wakes in.
Running the new tests alone covers all eight statements, plus six that no run had ever executed:
slice's short-leader rejection (the EOF case the bool return exists for)joinandstartfetch's error returnDarwin goes 823/1140 → 829/1140, so linux should go 827 → 833 (73.07%).
The floor stays at 72, deliberately. Ratcheting to the new measurement would spend the margin this
work exists to create, and buy back the flake the moment another statement turns out to be
load-dependent. The margin is the deliverable. Per
.coverage-floors' own rule the real number has tobe read from this PR's
coveragelog, not a local run.Mutation testing
Six mutations, each a compiling one-or-two-line change, each caught:
slicedrops the negative-start checkslicetable, "a range starting before the fetch"slicechecks the claimed length, not the bytes heldjoinnever finds a leaderjointablefetchignores the leader's errorcoveringLockednever matchesfetchreturns its error before retiring the flightTwo of those changed the tests, which is the point of running them.
joinreturningnilsurvived the first pass. It is invisible to any GET-count assertion, becausefetchfalls through tostartandstart's owncoveringLockedfinds the same leader and servesthe follower from the second window. So the
joinat the top offetchis an optimization, not abehavioural gate, and it needed owning directly rather than through
fetch. Invisible is notharmless: the
selfa follower registers in that window advertises a range nobody is fetching, andunclaimedStarttrims prefetches against exactly that list.The failed-leader test also passed with and without the
leader.err == nilcheck, becausefetchUncachedreturns nil data on failure, soslicerejects the leader on length alone and theerror check is redundant in production. That leader now holds bytes it must not hand over, which is
what makes the branch load-bearing — the comment on the
fetchesfield commits to a read notinheriting a prefetch's deadline, so the branch is worth owning.
And the error test uses
Fatal, notError, on the still-advertised check: continuing past it joins aflight whose
donechannel nothing closes, which turned that mutation from a 0.05s failure into aten-minute package timeout whose panic names a goroutine rather than a cause.
Two corrections to
.coverage-floorsBoth measured, not reasoned about.
The darwin/linux gap is not a denominator difference. The file said the two platforms "do not
even have the same denominator" because
internal/fusecompilesunmount_path_linux.go(52lines) on CI and
unmount_path_darwin.go(44) locally. Coverage counts statements, and bothfiles contribute exactly 2 — the package totals 1140 on both platforms. The real gap is seven
blocks in
mount.goandxattr.gothat one platform executes and the other does not. Theconclusion it drew was right and the reason it gave was not, which is the kind that survives.
The denominator moves with the toolchain, which is a larger effect and was not known. Go
1.26.6 counts 1140 statements in this package; Go 1.27.1 counts 1790, because it splits
coverage blocks far more finely —
filesystem.goalone goes from 209 blocks to 298. AGOTOOLCHAIN=automachine with a newer Go thango.mod's gets the finer granularity silently:1.27.1 measured this package at 71.96% where 1.26.6 measured 72.19%, same tests, same tree. A local
floor check has to pin the toolchain, and every floor in that file shifts when CI's Go moves to
1.27 — worth knowing before that bump lands.
Not done
filesystem.go:1167.49,1171.5(2 statements) — the success return inside the double-check window —stays uncovered. It requires a covering fetch to appear between
fetch'sjoinand itsstart, twomutex acquisitions in the same goroutine with no yield point between them.
testaws'OnFirehookexists for making exactly this kind of race deterministic, but it fires during an HTTP request and
there is no request in that window. Covering it would mean adding a test-only seam to production code,
which did not seem worth 2 statements — but it is a real gap rather than an oversight, so it is stated
rather than left to be rediscovered.
Verification
go test -race ./internal/fuse/and./internal/config/both pass (the latter parses.coverage-floors).golangci-lintreports 3 pre-existingmodernizefindings inerrno.goandxattr_oracle_test.go, files this PR does not touch, and CI lints--new-from-merge-base. Allmeasurements above were taken under
GOTOOLCHAIN=go1.26.6for the reason in correction 2.