test(lsp): wait for a killed server before reading its goroutine dump - #607
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This branch has not been deployed
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.
What and why
TestSilentServerFailsWithinDeadline(cmd/sysml-lsp/lifecycle_test.go) fails at random in the race job:Root cause. 27cbe61 (
test(lsp): fail fast with the server's goroutine dump when it stays silent) madereadBysendSIGQUITto a silent server and quote its stderr in the failure. The test harness captures stderr throughcmd.Stderr = &lockedBuffer{}. Because that writer is not an*os.File,os/execreads the child's stderr pipe on a goroutine of its own and only guarantees the copy is complete whencmd.Waitreturns.readByreads.stderr.String()as soon as the child's stdout hit EOF — the child had already exited with its dump written to the pipe, but nothing had waited for the copy to land in the buffer. Whether the dump appeared in the failure message was a race against that goroutine, lost under load (the race detector, a busy runner).Fix. The two killed-server failure paths in
readBynow go throughkilledStderr, which waits for the process (waitStatus, bounded by the same 10 s the 5 sKillfallback indumpAndKillmakes safe) before reading the buffer:waitStatusrecords that the process was waited for, so thet.Cleanupdoes not wait twice. The non-killed paths are unchanged: there the server is still running and its stderr is informational.How it was verified
Reproduced on
developand confirmed gone with the fix, same machine and load (16 busy-loop processes, race-instrumented test binary,-test.count=100):GOMAXPROCS=1GOMAXPROCS=2develop(65b98e5)want goroutine dumpGates:
gofmt -l .prints nothing;go build ./...;go vet ./...;go test -count=1 -race ./cmd/sysml-lsp;go test -count=1 ./...withOPENSYSML_REQUIRE_TRAINING_CORPUS=1 OPENSYSML_REQUIRE_PILOT_CORPORA=1 OPENSYSML_REQUIRE_PILOT_LIBRARY_XMI=1;python3 scripts/changelog.py check.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (none moved)F4,K5) in the body, docs, or changelog