Run multi-tenant queries in parallel.#10129
Closed
jeschkies wants to merge 6 commits into
Closed
Conversation
jeschkies
commented
Aug 1, 2023
| func(_ context.Context, idx int) error { | ||
| res, err := jobs[idx]() | ||
| if res != nil { | ||
| results = append(results, res...) |
Contributor
Author
There was a problem hiding this comment.
I don't think this was thread safe so I've replace the logic.
| iters[i] = NewTenantSampleIterator(iter, id) | ||
| i++ | ||
| id := id | ||
| p.Go(func(ctx context.Context) (iter.SampleIterator, error) { |
Contributor
Author
There was a problem hiding this comment.
iter.MapErr would be a little nicer but it does not work with a context and cancel on error. There's one (sourcegraph/conc#114) in the work.
jeschkies
commented
Aug 4, 2023
| id := id | ||
| p.Go(func(c context.Context) (iter.SampleIterator, error) { | ||
| singleContext := user.InjectOrgID(c, id) | ||
| iter, err := q.Querier.SelectSamples(singleContext, params) |
Contributor
Author
There was a problem hiding this comment.
This fails with a cancelled context when run a second time. I have a hard time understanding why.
Contributor
|
@jeschkies what shall we do with this? |
Contributor
|
Closing for now, we can revive it later if we want to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Previously the multi-tenant queries would run in sequence which might have slowed them down. That is why we are going to execute them in a small worker pool.
The tests have been update as well, since they were faulty.
Checklist
CONTRIBUTING.mdguide (required)CHANGELOG.mdupdatedadd-to-release-noteslabeldocs/sources/setup/upgrade/_index.mdproduction/helm/loki/Chart.yamland updateproduction/helm/loki/CHANGELOG.mdandproduction/helm/loki/README.md. Example PR