test(phlaredb): drain bidi streams instead of cancelling mid-flight#5157
Merged
Conversation
Test_QueryNotInitializedHead's bidi subtests sent one request then cancelled the context immediately. Under -race on Go 1.25 this races inside net/http: the HTTP/2 reset triggered by cancel spawns a goroutine that calls readTrackingBody.Close() while the original roundTrip goroutine is still touching the same struct. Extract a closeBidi helper that signals end-of-send and drains the response side, so the request body finishes on the normal codepath and never enters the reset handler. The parent test's intent — queries on an uninitialized head don't panic — is preserved; only the cancel-mid-RPC variant is dropped.
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.
Summary
Test_QueryNotInitializedHeadbidi subtests under-raceon Go 1.25closeBidihelper that signals end-of-send and drains the response side, avoiding the HTTP/2 reset path that races insidenet/httpTest plan
go test -race ./pkg/phlaredb/...to verify no race detector hitsNote
Low Risk
Low risk: test-only changes that adjust bidi stream shutdown semantics to avoid a Go 1.25
-raceissue, with no production code paths affected.Overview
Updates
Test_QueryNotInitializedHeadbidi subtests to stop cancelling the request context mid-stream and instead gracefully close the Connect bidi streams.Adds a generic
closeBidihelper that callsCloseRequest(), drainsReceive()until EOF, thenCloseResponse(), avoiding the HTTP/2 reset path that was triggering-racefailures on Go 1.25.Reviewed by Cursor Bugbot for commit f3444c9. Bugbot is set up for automated code reviews on this repo. Configure here.