Skip to content

Commit

Permalink
Revert "Revert "query: Close() after using query (thanos-io#5410)""
Browse files Browse the repository at this point in the history
This reverts commit 5f2fde8.
  • Loading branch information
GiedriusS committed Aug 10, 2022
1 parent 31cd60a commit 33290f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/api/query/grpc.go
Expand Up @@ -84,6 +84,7 @@ func (g *GRPCAPI) Query(request *querypb.QueryRequest, server querypb.Query_Quer
if err != nil {
return err
}
defer qry.Close()

result := qry.Exec(ctx)
if err := server.Send(querypb.NewQueryWarningsResponse(result.Warnings)); err != nil {
Expand Down Expand Up @@ -157,6 +158,7 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que
if err != nil {
return err
}
defer qry.Close()

result := qry.Exec(ctx)
if err := srv.Send(querypb.NewQueryRangeWarningsResponse(result.Warnings)); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/query/v1.go
Expand Up @@ -374,6 +374,7 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}
}
defer qry.Close()

tracing.DoInSpan(ctx, "query_gate_ismyturn", func(ctx context.Context) {
err = qapi.gate.Start(ctx)
Expand Down Expand Up @@ -502,6 +503,7 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
if err != nil {
return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}
}
defer qry.Close()

tracing.DoInSpan(ctx, "query_gate_ismyturn", func(ctx context.Context) {
err = qapi.gate.Start(ctx)
Expand Down

0 comments on commit 33290f1

Please sign in to comment.