Repository navigation
fix: 🐛✅ Fix flaky lease downgrade test - #892
Conversation
Signed-off-by: Evaline Ju <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Summary
This removes a flake in TestDowngradeGraceDoesNotCutAfterAnExecStopped. The old wait (pinnedCount == 2) counted B from routeExec onwards, before B was queued on execGate, so SetMode could reach the gate first. The new wait requires B to be parked in execLease's gate select. Go queues blocked senders first-come first-served, and runtime.Stack stops the world while it takes the snapshot, so B is ahead of SetMode.
Verified locally on Go 1.27.3: this test passes 200/200 and 50/50 with -race, it passes with GOTRACEBACK=system, and the full vmpool package passes three runs in a row (-count=3). One nit inline.
Author: evaline-ju (MEMBER — maintainer)
Areas reviewed: Go tests (vmpool)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: all checks pass
Assisted-By: Claude Code
| // is fn (`(*pool).execLease`). Unlike pinnedCount, which counts an Exec from routeExec on, | ||
| // one counted here is already queued on the channels it waits for, so it gets the gate | ||
| // before any waiter that queues after it. | ||
| func parkedIn(fn string) int { |
There was a problem hiding this comment.
nit — parkedIn counts across every goroutine in the test binary, and the test waits for exactly 1. A goroutine some other test leaves parked in execLease's gate select (a failure, a future test, -count=N) would make this test time out at 2, with nothing pointing at the real cause.
It's fine today (the package passes -count=3 locally), but scoping the count to this pool would make it independent of other tests, for example matching the receiver argument in the frame with fmt.Sprintf(".%s(%p", fn, p).
There was a problem hiding this comment.
Scoped parkedIn to the pool's receiver as suggested in 55511d5; I checked that the parked frame prints the exact pointer.
There was a problem hiding this comment.
Correction: on linux/amd64 the parked frame prints the receiver as _, so the %p match never matched and CI failed. I replaced it in 09159c1 with a baseline: the test counts the parked execLease goroutines before starting B, then waits for one more.
Signed-off-by: Evaline Ju <[email protected]>
Signed-off-by: Evaline Ju <[email protected]>
Summary
The test checked a counter that goes up a moment before a queued command actually waits for the lease, so on a busy CI machine another step could sometimes cut in ahead of it. It now waits until the command is really in line, so the order no longer depends on timing.
Flake observed on CI on another PR: https://github.com/rossoctl/moca/actions/runs/44351321113/job/134967418439
Checklist
git commit -s).make lintand the tests for the touched packages pass.docs/page, with the right maturity label (seedocs/CONTRIBUTING-DOCS.md). - N/Amake check-linkspasses if any Markdown changed. - N/Adocs/specs/README.mdordocs/adrs/README.md. - N/A