Skip to content

Commit

Permalink
Fix flaky `TestStoreGatewayStreamReader_AbortsWhenParentContextCancel…
Browse files Browse the repository at this point in the history
…led` (#9397)
  • Loading branch information
charleskorn authored Sep 25, 2024
1 parent 0f32622 commit bc65760
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/querier/block_streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ func (s *storeGatewayStreamReader) readStream(log *spanlogger.SpanLogger) error
}

func (s *storeGatewayStreamReader) sendBatch(c *storepb.StreamingChunksBatch) error {
if err := s.ctx.Err(); err != nil {
// If the context is already cancelled, stop now for the same reasons as below.
// We do this extra check here to ensure that we don't get unlucky and continue to send to seriesChunksChan even if
// the context is cancelled because the consumer of the stream is reading faster than we can read new batches.
return fmt.Errorf("aborted stream because query was cancelled: %w", context.Cause(s.ctx))
}

select {
case <-s.ctx.Done():
// Why do we abort if the context is done?
Expand Down

0 comments on commit bc65760

Please sign in to comment.