You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bb7ddcc
Browse filesBrowse the repository at this point in the historyBrowse files
fix(scanner): Pass 2 dropped by Pass 1 slot race; clock-independent staging deadline test (#1648)
Fixes the two E2E failures on main after #1628 (#1602) that block
v0.71.0.
## Root causes
1. **macOS: `TestServiceStartScanDeepOnRunsSourceResolutionAndPass2`**
(run 39002404847). Not caused by #1628 (Pass 2 staging/in-process path
unchanged; #1628's own main run was green). Real production race:
`OnScanCompleted` spawns `startPass2` inside `executeScan`, before the
deferred `clearActiveJob` frees the server's engine slot. When Pass 2
reaches `StartScan` first it is rejected with "scan already in
progress", logged at Warn and dropped: no Pass 2 job is ever saved (test
times out after 10s) and the resolved source dir leaked. Slow runners
widen the window.
2. **Windows: `TestStagedSource_ScanDeadlineCoversStaging`**. A 1ns
`context.WithTimeout` is not observably expired on the coarse Windows
clock, so staging of a tiny dir finished before the ctx check.
## Fix
- `ErrScanInProgress` sentinel; `startPass2` retries (bounded 10s) while
the blocking job is a Pass-1 job, releases the resolved source and saves
a failed Pass 2 job if it still cannot start.
- Staging test now uses a 20ms timeout, plus a non-skipped source file
and a stall in the `stagingAfterReadBatch` seam past the deadline, so
the following ctx check deterministically fails. Still proves staging
runs under the scan deadline.
- New regression test `TestStartPass2WaitsForPass1SlotRelease` (fails
before: Pass 2 saved as failed with "scan already in progress").
## Verification
`go test -race ./internal/security/...` green, `-count=30` on the
touched tests, `GOOS=windows go vet`, both golangci-lint runs (bare and
`--build-tags server`) 0 issues. The macOS flake did not reproduce
locally under CPU load; diagnosis is from code plus the deterministic
regression test.
0 commit comments