Repository navigation
fix(longops): drain process output before Wait to avoid truncated lines - #151
Merged
Merged
Conversation
With StdoutPipe, Wait closes the read end of the pipe as soon as the process exits, so calling Wait before draining the scanner could lose whatever was still buffered: on a loaded arm64 runner the release CI hit lines=[] for a printf that wrote and exited immediately (#150). Read to EOF first, then reap. Closes #150
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 #150.
Manager.watchcalledcmd.Wait()before draining the stdout scanner. WithStdoutPipe,Waitcloses the read end of the pipe as soon as the process exits (documented in os/exec: it is incorrect to callWaitbefore all reads from the pipe have completed), so whatever was still buffered could be lost. The release CI for v2.9.28 hit exactly this on the arm64 runner:TestStartCapturesOutputgotlines=[]for aprintfthat wrote two lines and exited immediately.The fix reorders the sequence: drain the scanner to EOF first, then reap with
Wait. EOF only happens after the process closes its stdout, so all lines are captured before the op is marked done. This also protects real rewrite/replication progress lines from truncation.Verification:
go vetclean;go test -race -run "TestStart|TestCancel" -count=100 ./internal/longops/pass (100 iterations);go test -race -count=3 ./internal/longops/pass; fullgo test ./internal/...pass.