diff --git a/go/arrow/flight/flightsql/driver/driver_test.go b/go/arrow/flight/flightsql/driver/driver_test.go index 3ec8533979a32..4449b390974a7 100644 --- a/go/arrow/flight/flightsql/driver/driver_test.go +++ b/go/arrow/flight/flightsql/driver/driver_test.go @@ -812,6 +812,17 @@ func (s *MockServer) DoPutPreparedStatementQuery(ctx context.Context, qry flight return fmt.Errorf("parameter schema: %w", arrow.ErrInvalid) } + // GH-35328: it's rare, but this function can complete execution and return + // closing the reader *after* the schema is written but *before* the parameter batch + // is written (race condition based on goroutine scheduling). In that situation, + // the client call to Write the parameter record batch will return an io.EOF because + // this end of the connection will have closed before it attempted to send the batch. + // This created a flaky test situation that was difficult to reproduce (1-4 failures + // in 5000 runs). We can avoid this flakiness by simply *explicitly* draining the + // record batch messages from the reader before returning. + for r.Next() { + } + return nil }