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

Fix sending all series to all ingesters #3458

Merged
merged 4 commits into from Nov 17, 2022

Conversation

pstibrany
Copy link
Member

What this PR does

This PR fixes bug introduced in #3386: series and metadata should be properly sharded into ingesters. This PR also adds test to verify that each ingester only received series that "belong" to it based on ingester tokens.

Checklist

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

Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
@pstibrany pstibrany requested a review from a team as a code owner November 16, 2022 14:59
Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

AFAICT it looks good (does what it should), although I'm relatively new to the code. It's probably best to get a review also from someone more familiar.

See suggestions though.

pkg/distributor/distributor_test.go Show resolved Hide resolved
pkg/distributor/distributor.go Show resolved Hide resolved
@aknuds1 aknuds1 added bug Something isn't working component/distributor labels Nov 16, 2022
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@pstibrany pstibrany enabled auto-merge (squash) November 17, 2022 07:52
@pstibrany pstibrany merged commit e1e33e7 into main Nov 17, 2022
@pstibrany pstibrany deleted the fix-sending-all-series-to-all-ingesters branch November 17, 2022 08:05

// we must not re-use buffers now until all DoBatch goroutines have finished,
// so set this flag false and pass cleanup() to DoBatch.
cleanupInDefer = false

err = ring.DoBatch(ctx, ring.WriteNoExtend, subRing, keys, func(ingester ring.InstanceDesc, indexes []int) error {
err := d.send(localCtx, ingester, req.Timeseries, req.Metadata, req.Source)
timeseries := make([]mimirpb.PreallocTimeseries, 0, len(indexes))
var metadata []*mimirpb.MetricMetadata
Copy link
Contributor

Choose a reason for hiding this comment

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

why not

metadata := make([]*mimirpb.MetricMetadata, 0, len(indexes) - initialMetadataIndex)

Copy link
Member Author

@pstibrany pstibrany Nov 17, 2022

Choose a reason for hiding this comment

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

I don't think that's correct optimization, and could lead to panics.

Say series keys is [231, 342, 532, 984, 278, 1873, 784, 827], and metadataKeys is [478, 874, 983].
Then keys is [231, 342, 532, 984, 278, 1873, 784, 827, 478, 874, 983], and initialMetadataIndex=8.

If a given ingester should get values < 500, then indexes would be: [0, 1, 4, 8] (indexes into keys that are < 500).

We know that indexes below initialMetadataIndex refer to the keys, but we don't know how many there are. In this case, len(indexes) - initialMetadataIndex would even be negative number.

Given that most write requests push series, and not metadata, we optimize for that case: we preallocate slice for timeseries, but not metadata.

manohar-koukuntla pushed a commit to manohar-koukuntla/mimir that referenced this pull request Nov 17, 2022
* Fix sending all series to all ingesters.
* Add test.
* CHANGELOG.md

Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
masonmei pushed a commit to udmire/mimir that referenced this pull request Dec 16, 2022
* Fix sending all series to all ingesters.
* Add test.
* CHANGELOG.md

Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component/distributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants