Skip to content

Commit

Permalink
Add function comment
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <[email protected]>
  • Loading branch information
pracucci committed Apr 11, 2024
1 parent 4ed5584 commit d646932
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,13 +1345,12 @@ func (d *Distributor) push(ctx context.Context, pushReq *Request) error {
// once all backend requests have completed (see cleanup function passed to sendWriteRequestToBackends()).
cleanupInDefer = false

return d.sendWriteRequestToBackends(ctx, userID, req, keys, initialMetadataIndex, tenantRing, func() {
// This cleanup function is called once all requests to all backends have been completed.
// At this point is safe to finally release the original pushReq resources back to the pool.
pushReq.CleanUp()
})
return d.sendWriteRequestToBackends(ctx, userID, req, keys, initialMetadataIndex, tenantRing, pushReq.CleanUp)
}

// sendWriteRequestToBackends sends the input req data to backends (i.e. ingesters or partitions).
//
// The input cleanup function is guaranteed to be called after all requests to all backends have completed.
func (d *Distributor) sendWriteRequestToBackends(ctx context.Context, tenantID string, req *mimirpb.WriteRequest, keys []uint32, initialMetadataIndex int, tenantRing ring.DoBatchRing, cleanup func()) error {
// Use an independent context to make sure all backend instances (e.g. ingesters) get samples even if we return early.
// It will still take a while to lookup the ring and calculate which instance gets which series,
Expand Down

0 comments on commit d646932

Please sign in to comment.