Skip to content

Fixes an issue in the index chunks/series intersect code. #2796

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [FEATURE] Introduced `ruler.for-grace-period`, Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period. #2783
* [FEATURE] Introduced `ruler.for-resend-delay`, Minimum amount of time to wait before resending an alert to Alertmanager. #2783
* [ENHANCEMENT] Experimental: Querier can now optionally query secondary store. This is specified by using `-querier.second-store-engine` option, with values `chunks` or `tsdb`. Standard configuration options for this store are used. Additionally, this querying can be configured to happen only for queries that need data older than `-querier.use-second-store-before-time`. Default value of zero will always query secondary store. #2747
* [BUGFIX] Fixed a bug in the index intersect code causing storage to return more chunks/series than required. #2796
* [BUGFIX] Fixed the number of reported keys in the background cache queue. #2764
* [BUGFIX] Fix race in processing of headers in sharded queries. #2762

Expand Down
4 changes: 3 additions & 1 deletion pkg/chunk/chunk_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,13 @@ func (c *store) lookupChunksByMetricName(ctx context.Context, userID string, fro
// Receive chunkSets from all matchers
var chunkIDs []string
var lastErr error
var initialized bool
for i := 0; i < len(matchers); i++ {
select {
case incoming := <-incomingChunkIDs:
if chunkIDs == nil {
if !initialized {
chunkIDs = incoming
initialized = true
} else {
chunkIDs = intersectStrings(chunkIDs, incoming)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/chunk/chunk_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func TestChunkStore_Get(t *testing.T) {
query: `foo{toms="code", bar="baz"}`,
expect: []Chunk{fooChunk1},
},
{
query: `foo{a="b", bar="baz"}`,
expect: nil,
},
{
query: `{__name__=~"foo"}`,
err: "query must contain metric name",
Expand Down
4 changes: 3 additions & 1 deletion pkg/chunk/series_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,14 @@ func (c *seriesStore) lookupSeriesByMetricNameMatchers(ctx context.Context, from
var lastErr error
var cardinalityExceededErrors int
var cardinalityExceededError CardinalityExceededError
var initialized bool
for i := 0; i < len(matchers); i++ {
select {
case incoming := <-incomingIDs:
preIntersectionCount += len(incoming)
if ids == nil {
if !initialized {
ids = incoming
initialized = true
} else {
ids = intersectStrings(ids, incoming)
}
Expand Down