Skip to content

test(phlaredb): drain bidi streams instead of cancelling mid-flight#5157

Merged
simonswine merged 1 commit into
mainfrom
20260515_test-race-flake-bidi-client
May 15, 2026
Merged

test(phlaredb): drain bidi streams instead of cancelling mid-flight#5157
simonswine merged 1 commit into
mainfrom
20260515_test-race-flake-bidi-client

Conversation

@simonswine
Copy link
Copy Markdown
Contributor

@simonswine simonswine commented May 15, 2026

Summary

  • Fixes a race condition in Test_QueryNotInitializedHead bidi subtests under -race on Go 1.25
  • Extracts a closeBidi helper that signals end-of-send and drains the response side, avoiding the HTTP/2 reset path that races inside net/http
  • The test's original intent (queries on an uninitialized head don't panic) is preserved

Test plan

  • Run go test -race ./pkg/phlaredb/... to verify no race detector hits

Note

Low Risk
Low risk: test-only changes that adjust bidi stream shutdown semantics to avoid a Go 1.25 -race issue, with no production code paths affected.

Overview
Updates Test_QueryNotInitializedHead bidi subtests to stop cancelling the request context mid-stream and instead gracefully close the Connect bidi streams.

Adds a generic closeBidi helper that calls CloseRequest(), drains Receive() until EOF, then CloseResponse(), avoiding the HTTP/2 reset path that was triggering -race failures on Go 1.25.

Reviewed by Cursor Bugbot for commit f3444c9. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@simonswine simonswine requested a review from a team as a code owner May 15, 2026 08:40
Copy link
Copy Markdown
Contributor

@alsoba13 alsoba13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonswine simonswine merged commit 2c3ab89 into main May 15, 2026
33 checks passed
@simonswine simonswine deleted the 20260515_test-race-flake-bidi-client branch May 15, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants