Skip to content

Conversation

jeschkies
Copy link
Contributor

@jeschkies jeschkies commented Aug 1, 2023

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

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR

@jeschkies jeschkies requested a review from a team as a code owner August 1, 2023 14:54
func(_ context.Context, idx int) error {
res, err := jobs[idx]()
if res != nil {
results = append(results, res...)
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 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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

id := id
p.Go(func(c context.Context) (iter.SampleIterator, error) {
singleContext := user.InjectOrgID(c, id)
iter, err := q.Querier.SelectSamples(singleContext, params)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails with a cancelled context when run a second time. I have a hard time understanding why.

@pull-request-size pull-request-size bot added size/M and removed size/L labels Aug 15, 2023
@dannykopping
Copy link
Contributor

@jeschkies what shall we do with this?

@dannykopping
Copy link
Contributor

Closing for now, we can revive it later if we want to.

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

Successfully merging this pull request may close these issues.

2 participants