Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1337 from grafana/always_cancel_context
Browse files Browse the repository at this point in the history
make sure cancel() always gets called
  • Loading branch information
Dieterbe authored May 30, 2019
2 parents d1381fc + 62f0f4a commit 450b376
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions api/graphite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ func (s *Server) graphiteTagFindSeries(ctx *middleware.Context, request models.G
func (s *Server) clusterFindByTag(ctx context.Context, orgId uint32, expressions []string, from int64, maxSeries int) ([]Series, error) {
data := models.IndexFindByTag{OrgId: orgId, Expr: expressions, From: from}
newCtx, cancel := context.WithCancel(ctx)
defer cancel()
responseChan, errorChan := s.peerQuerySpeculativeChan(newCtx, data, "clusterFindByTag", "/index/find_by_tag")

var allSeries []Series
Expand All @@ -1057,13 +1058,11 @@ func (s *Server) clusterFindByTag(ctx context.Context, orgId uint32, expressions
resp := models.IndexFindByTagResp{}
_, err := resp.UnmarshalMsg(r.buf)
if err != nil {
cancel()
return nil, err
}

// 0 disables the check, so only check if maxSeriesPerReq > 0
if maxSeriesPerReq > 0 && len(resp.Metrics)+len(allSeries) > maxSeries {
cancel()
return nil,
response.NewError(
http.StatusRequestEntityTooLarge,
Expand Down

0 comments on commit 450b376

Please sign in to comment.