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

Perform ingester pushes in a background context rather than the request context #736

Merged

Conversation

csmarchbanks
Copy link
Contributor

@csmarchbanks csmarchbanks commented Mar 7, 2018

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:
screen shot 2018-03-07 at 1 03 12 pm

@csmarchbanks csmarchbanks force-pushed the push-in-background-ctx branch from 60422d8 to 6c4d909 Compare March 7, 2018 20:29
@@ -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)
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@bboreham bboreham left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants