Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents panic using freed slice in pool #2000

Merged
Merged
Show file tree
Hide file tree
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: 2 additions & 1 deletion pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,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 @@ -248,7 +250,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
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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 firstPartialErr 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 @@ -183,8 +185,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 firstPartialErr != nil {
return &client.WriteResponse{}, httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(firstPartialErr, userID).Error())
}
Expand Down