fix(telemetry): make the launch-source once-guard goroutine-safe - #992
Merged
Conversation
Fixes #991 launchSourceOnceT was a bare done bool with no synchronization; concurrent DetectLaunchSourceOnce calls (two listeners' /api/v1/status handlers in practice) raced on the flag and the cached value. The guard now holds a mutex — Do is exclusive and the cached write is ordered before any post-Do read — and resetLaunchSourceOnce resets under the same lock instead of copying the struct. ## Testing - New TestDetectLaunchSourceOnceConcurrent (32 goroutines): DATA RACE before the fix, green after - Original repro green: go test -race ./internal/server -run TestE2E_DualListener_Concurrent - lint v2 0 issues
Deploying mcpproxy-docs with
|
| Latest commit: |
d68817a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4d7d0dc9.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-991-launch-source-race.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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 31828719168 --repo smart-mcp-proxy/mcpproxy-go
|
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 #991
launchSourceOnceTwas a baredone boolwith no synchronization — concurrentDetectLaunchSourceOnce()calls (two listeners'/api/v1/statushandlers in practice) raced on both the flag andlaunchSourceCached. The guard now holds a mutex (Do exclusive; cached write ordered before any post-Do read), andresetLaunchSourceOnceresets under the same lock instead of copying the struct.Testing
TestDetectLaunchSourceOnceConcurrent(32 goroutines) — reproduces the DATA RACE before the fix, green aftergo test -race ./internal/server -run TestE2E_DualListener_Concurrent