Skip to content

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
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