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
Conversation
Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
||
// 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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
* Fix sending all series to all ingesters. * Add test. * CHANGELOG.md Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
* Fix sending all series to all ingesters. * Add test. * CHANGELOG.md Signed-off-by: Peter Stibrany <pstibrany@gmail.com>
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
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]