Repository navigation
Conversation
acquireCompactLock stamped its lock file with pid+timestamp, and release compared that string to decide whether the lock was still its own. On Windows the system clock granularity is coarse (~0.5-15ms), so two acquisitions in the same process with no work between them can read the same time.Now(). Same pid + same timestamp = identical token, and A's release then deletes B's lock — leaving the pathname free for a third compaction to start alongside B's. The token is the only thing standing between a stale-lock cleanup and two concurrent compactions on the same BBolt database, so this is a correctness bug, not just the intermittent windows-latest failure of TestCompactLockReleaseDoesNotRemoveSomeoneElsesLock (introduced in #1214, seen on unrelated PRs #1215 and #1216). Add 16 crypto/rand bytes, hex-encoded, to the token. pid and started stay for whoever has to read a stale lock file. The lock protocol and the compaction flow are unchanged. Testing: compactLockNow is a seam so tests can freeze the clock, which is exactly the Windows condition. Frozen, the existing test reproduces the byte-identical windows-latest failure on macOS instead of by luck, and a new TestCompactLockTokenIsUniqueWithoutClockAdvance asserts the token property directly. Both fail without the nonce and pass with it, on every platform. Co-Authored-By: Claude Opus 5 <[email protected]>
Deploying mcpproxy-docs with
|
| Latest commit: |
ae829dd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://65ae2875.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-recursing-nash-945605.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 34050048343 --repo smart-mcp-proxy/mcpproxy-go
|
|
Duplicate of #1217, which has the same crypto/rand nonce fix and got there first. #1217 also handles the failure path correctly (it closes the file handle before The one thing this PR had that #1217 lacked — the |
Problem
TestCompactLockReleaseDoesNotRemoveSomeoneElsesLockfails intermittently on thewindows-latest"Build Binaries" job. It is not branch-specific — it failed on #1215 (a docs-only change) and on #1216, then passed on the next run of the same branch.It is also a real correctness bug, not just a flaky test.
acquireCompactLockstamps the lock file with:and release compares
string(current) != tokento decide whether the lock is still its own. On Windows the system clock granularity is coarse (~0.5-15ms), so two acquisitions in the same process with no work between them can read the sametime.Now(). Same pid + same timestamp = identical token, so A's release believes B's lock is its own and deletes it — freeing the pathname for a third compaction to run alongside B on the same BBolt database. Whether the two calls straddle a clock tick is what made it intermittent; the observed failures run in 0.00s.Fix
Add 16
crypto/randbytes, hex-encoded, to the token.pidandstartedstay for whoever has to diagnose a stale lock file. The lock protocol and the compaction flow are unchanged.Testing
compactLockNowis a seam so tests can freeze the clock — which is the Windows condition, made deterministic.TestCompactLockReleaseDoesNotRemoveSomeoneElsesLocknow freezes the clock, so it exercises the collision on every platform instead of by luck. With the nonce reverted it reproduces the byte-identical windows-latest failure on macOS:A's release removed B's lock, so a third compaction could start: stat …config.db.compact.lock: no such file or directory.TestCompactLockTokenIsUniqueWithoutClockAdvanceasserts the token property directly (acquire → read file → release → re-acquire → read file → compare).Both fail without the nonce and pass with it. Verified:
go test -count=5 ./cmd/mcpproxy/(green),go test -race(green),GOOS=windows go build ./...andGOOS=windows go test -c(both build),golangci-lint run --config .github/.golangci.yml ./cmd/mcpproxy/...→ 0 issues.Windows CI on this PR is the remaining confirmation.
🤖 Generated with Claude Code