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

Commit

Permalink
Merge pull request #25 from owen-d/patch/ingester-pool-error
Browse files Browse the repository at this point in the history
prevents error using freed slice in pool
  • Loading branch information
owen-d committed Jan 18, 2020
2 parents 6a33f49 + 252a1a8 commit 7c2efdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/ingester/ingester.go
Expand Up @@ -289,6 +289,8 @@ func (i *Ingester) Push(ctx old_ctx.Context, req *client.WriteRequest) (*client.
return i.v2Push(ctx, req)
}

defer client.ReuseSlice(req.Timeseries)

userID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, fmt.Errorf("no user id")
Expand All @@ -311,7 +313,6 @@ func (i *Ingester) Push(ctx old_ctx.Context, req *client.WriteRequest) (*client.
return nil, wrapWithUser(err, userID)
}
}
client.ReuseSlice(req.Timeseries)

if lastPartialErr != nil {
return &client.WriteResponse{}, lastPartialErr.WrapWithUser(userID).WrappedError()
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingester/ingester_v2.go
Expand Up @@ -82,6 +82,8 @@ func NewV2(cfg Config, clientConfig client.Config, limits *validation.Overrides,
func (i *Ingester) v2Push(ctx old_ctx.Context, req *client.WriteRequest) (*client.WriteResponse, error) {
var lastPartialErr error

defer client.ReuseSlice(req.Timeseries)

userID, err := user.ExtractOrgID(ctx)
if err != nil {
return nil, fmt.Errorf("no user id")
Expand Down Expand Up @@ -157,8 +159,6 @@ func (i *Ingester) v2Push(ctx old_ctx.Context, req *client.WriteRequest) (*clien
i.metrics.ingestedSamples.Add(float64(succeededSamplesCount))
i.metrics.ingestedSamplesFail.Add(float64(failedSamplesCount))

client.ReuseSlice(req.Timeseries)

if lastPartialErr != nil {
return &client.WriteResponse{}, httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(lastPartialErr, userID).Error())
}
Expand Down

0 comments on commit 7c2efdb

Please sign in to comment.