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

Add partitions ring support to Distributor.QueryStream() #7388

Merged
merged 7 commits into from
Feb 15, 2024

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented Feb 14, 2024

What this PR does

In this PR I'm adding partitions ring support to Distributor.QueryStream(). Other Distributor's query functions don't use partitions ring yet and their support will be introduced in follow up PRs.

Notes:

  • Most of work has been done by @dimitarvdimitrov , mentioned as co-author in the commit.
  • I've introduced a new config option -querier.prefer-availability-zone. The config is hidden in the doc because currently used only by experimental ingest storage.

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

leaving a partial review, will continue reviewing tomorrow

Comment on lines +1524 to +1526
if len(replicationSets) == 1 {
zoneSorter = queryIngestersRingZoneSorter(replicationSets[0])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, but i'd even panic if that's not the case

}
}

// LabelValuesForLabelName returns all of the label values that are associated with a given label name.
func (d *Distributor) LabelValuesForLabelName(ctx context.Context, from, to model.Time, labelName model.LabelName, matchers ...*labels.Matcher) ([]string, error) {
replicationSet, err := d.GetIngesters(ctx)
//nolint:staticcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

is this because of the deprecated notice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The usage of deprecated functions will disappear as soon as I complete this work (over the course of few more PRs).

pkg/distributor/query_ingest_storage_test.go Show resolved Hide resolved
Base automatically changed from write-and-consume-partitions to main February 15, 2024 09:31
pracucci and others added 2 commits February 15, 2024 11:00
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Co-authored-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
…estStorage

Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci marked this pull request as ready for review February 15, 2024 10:39
@pracucci pracucci requested review from grafanabot and a team as code owners February 15, 2024 10:39
Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Very nice set of tests. Good job @dimitarvdimitrov and @pracucci!

pkg/distributor/query.go Outdated Show resolved Hide resolved
expectedQueriedIngesters: 5 /* zone-a */ + 2, /* the two failed fall back to zone-b */
expectedErr: errFail,
},
"should succeed if there unhealthy ingesters in every zone but unhealthy ingesters own different partitions": {
Copy link
Member

Choose a reason for hiding this comment

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

This is very nice property.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The coolest property of the new system ;)

@pracucci
Copy link
Collaborator Author

Very nice set of tests. Good job @dimitarvdimitrov

All done by Dimitar!

@pstibrany
Copy link
Member

Very nice set of tests. Good job @dimitarvdimitrov

All done by Dimitar!

I thought so, but wasn't sure :)

Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
@pracucci
Copy link
Collaborator Author

Going to merge it since I don't think that what we do in this PR is particularly contentious. I there will be post merge comments, I will quickly address them in a follow up PR.

@pracucci pracucci enabled auto-merge (squash) February 15, 2024 14:57
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

LGTM, left an idea for one more test case, but happy to do it in a follow-up PR if you don't want to wait for CI on this one again

Comment on lines +409 to +413
"should fail if all the ingesters owning a partition are in JOINING state": {
ingesterStateByZone: map[string]ingesterZoneState{
"zone-a": {numIngesters: 5, happyIngesters: 5, ringStates: []ring.InstanceState{ring.JOINING, ring.ACTIVE, ring.ACTIVE, ring.ACTIVE, ring.ACTIVE}},
"zone-b": {numIngesters: 5, happyIngesters: 5, ringStates: []ring.InstanceState{ring.JOINING, ring.ACTIVE, ring.ACTIVE, ring.ACTIVE, ring.ACTIVE}},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

you can also add a case where different ingesters in the two zones are LEAVING (or JOINING) but the query still succeeds

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, done in 19650e3

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.

None yet

3 participants