Repository navigation
fix(scanner): Pass 2 dropped by Pass 1 slot race; clock-independent staging deadline test - #1648
Merged
Merged
Conversation
…ging-deadline test clock-independent Pass 1's OnScanCompleted spawns Pass 2 inside executeScan, before the deferred clearActiveJob frees the server's slot. A fast Pass 2 got "scan already in progress" from StartScan and was silently dropped (no job saved, source cleanup leaked). startPass2 now waits (bounded, 10s) while the blocker is a Pass-1 job, releases the resolved source on rejection and records a failed Pass 2 job. Fixes the macOS flake in TestServiceStartScanDeepOnRunsSourceResolutionAndPass2. TestStagedSource_ScanDeadlineCoversStaging relied on a 1ns timeout being expired when staging checked ctx; the Windows coarse clock makes that false. It now uses a 20ms timeout and stalls inside staging past the deadline. Follow-up to #1628 (#1602).
Deploying mcpproxy-docs with
|
| Latest commit: |
c27da55
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c1f7fe25.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-scanner-e2e-flakes.mcpproxy-docs.pages.dev |
… Pass 2 A user-triggered rescan that registers after the originating Pass 1 is cleared must not hold Pass 2 for the full slot wait.
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 39004485680 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Fixes the two E2E failures on main after #1628 (#1602) that block v0.71.0.
Root causes
TestServiceStartScanDeepOnRunsSourceResolutionAndPass2(run 39002404847). Not caused by fix(scanner): bound source staging enumeration and run it under the scan timeout #1628 (Pass 2 staging/in-process path unchanged; fix(scanner): bound source staging enumeration and run it under the scan timeout #1628's own main run was green). Real production race:OnScanCompletedspawnsstartPass2insideexecuteScan, before the deferredclearActiveJobfrees the server's engine slot. When Pass 2 reachesStartScanfirst 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.TestStagedSource_ScanDeadlineCoversStaging. A 1nscontext.WithTimeoutis not observably expired on the coarse Windows clock, so staging of a tiny dir finished before the ctx check.Fix
ErrScanInProgresssentinel;startPass2retries (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.stagingAfterReadBatchseam past the deadline, so the following ctx check deterministically fails. Still proves staging runs under the scan deadline.TestStartPass2WaitsForPass1SlotRelease(fails before: Pass 2 saved as failed with "scan already in progress").Verification
go test -race ./internal/security/...green,-count=30on 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.