-
Notifications
You must be signed in to change notification settings - Fork 808
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
Perform ingester pushes in a background context rather than the request context #736
Perform ingester pushes in a background context rather than the request context #736
Conversation
60422d8
to
6c4d909
Compare
pkg/distributor/distributor.go
Outdated
@@ -350,7 +351,14 @@ func (d *Distributor) Push(ctx context.Context, req *client.WriteRequest) (*clie | |||
defer cancel() // cancel the timeout to release resources | |||
for ingester, samples := range samplesByIngester { | |||
go func(ingester *ring.IngesterDesc, samples []*sampleTracker) { | |||
d.sendSamples(ctx, ingester, samples, &pushTracker) | |||
// Use a background context to make sure all ingesters get samples even if we return early | |||
localCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the WithTimeout
on line 350?
Could we use the same timeout parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may well be the cancel()
on line 351 that is causing the trouble, so it may not be necessary to start from Background()
if you took that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like removing WithTimeout on line 350 and using the same timeout parameter for the background calls.
I believe if we don't have the background context, the context from our request is cancelled as soon as the response is returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really neat, thanks!
Use a background context for the pushes to the ingester. This allows the context to continue after the request is returned in order to finish writing to
replicas
ingesters, rather than stopping after a quorum.Solution to: #730
Alternative to: #732
Jaeger trace showing the third push finishing after the request is done: