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

make sure cancel always gets called #1337

Merged
merged 1 commit into from
May 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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