carlos / platform Public

Three load-dependent test flakes seen in branch CI (edge awake throttle, rootfs start lock, fleet metrics speed rows) open

Seen in CI on instance-egress-sizes-328-329 (tip 1a447518, 2026-10-26). All three tests come from main, and none touches code that branch changes. Each one passes repeatedly when run alone on a dev box (-count=20 to -count=30). They fail only under the full gate's parallel load.

  • internal/edge TestAwakeThrottleClosesAndRefusesUpgrades (planthrottle_test.go:144, "the socket stayed open after the account was awake-throttled"). Failed in 2 of that branch's 4 CI runs. The test writes "two" right after CloseAccountUpgrades returns. If the hijacked connection's close lands after the echo backend answers, the read succeeds. The test should wait for the close (read until EOF with a deadline) rather than assume it is synchronous.
  • internal/instancectl TestAStartWhoseRequestEndsWhileWaitingForTheLockLaysNothingOut (rootfs_test.go:2672, "systemd saw 2 starts ... want one"), followed by "http: panic serving ...: the removal's files() path failed".
  • internal/console TestFleetMetricsSpeedRowsNameTheMethod (perfspeed_test.go:69, /fleet/metrics lacks "<td>GET /fleet/architecture</td>"). This looks order- or timing-dependent on which requests were recorded first.

TestAStartWhoseRequestEndsWhileWaitingForTheLockLaysNothingOut is racy on main (from d34c0a72). The test is wrong, not the production code.

Measured on a loaded box, 50 runs at each of GOMAXPROCS 1, 2, 4 and 16:

| | fails | |---|---| | main a64f5a41 | 71/200 | | instance-egress-sizes-328-329 | 76/200 |

At GOMAXPROCS=1 it fails about 90% of the time on both. That branch doesn't touch rootfs.go or rootfs_unitlock.go.

Cause. The test assumes the server notices start B's client hang-up (a 100 ms client deadline) before start A finishes and releases the unit's lock. B's request context only ends when net/http's background read sees the closed connection, and when that happens is up to the scheduler. If A's release (rootfs.go:680) wakes B first, B takes the lock with a live context. It then passes both checks (rootfs_unitlock.go:108 and rootfs.go:762) and starts the unit a second time. A server cannot act on a hang-up it has not seen yet (the #292 unseen-cancel race), so the production code is right.

The http: panic serving ...: the removal's files() path failed line is unrelated. It comes from TestAPanicDuringARemovalLeavesTheUnitsLockFree's deliberate panic.

Fix (test only). Order B's end explicitly instead of timing it with a client deadline:

  1. Send B in a goroutine with a cancellable context.
  2. Wait until the unit's lock entry has two references (A's hold and B's wait).
  3. Cancel B's context and wait for Do to return.
  4. Wait until the entry is back to one reference before the hook returns, so A carries on.

Each wait polls every 1 ms with a 5 s deadline. Add a test-only helper next to rootfsLockCount:

func (s *Server) rootfsLockRefs(unit string) int {
	s.rootfsLocksMu.Lock()
	defer s.rootfsLocksMu.Unlock()
	if e := s.rootfsLocks[unit]; e != nil {
		return e.refs
	}
	return 0
}

Checked in scratch:

  • With a listener that notices hang-ups 500 ms late, the current hook fails 3/3 and the ordered hook passes.
  • The ordered hook passed 60/60 at -cpu 1,4,16.
  • It still fails when holdRootfsUnit ignores its context, so it still guards fix L3.

The rootfs start-lock test flake is fixed on main as e49282b (test only: B's hang-up is ordered, not raced). The edge throttle and fleet metrics flakes above are still open.