diff --git a/chunk_store.go b/chunk_store.go index 41eef9c41be5..4363696cf0df 100644 --- a/chunk_store.go +++ b/chunk_store.go @@ -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) } diff --git a/chunk_store_test.go b/chunk_store_test.go index f983f71f3077..24a49d30c7d7 100644 --- a/chunk_store_test.go +++ b/chunk_store_test.go @@ -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", diff --git a/series_store.go b/series_store.go index a1e062f9770c..4792ca1ae2e0 100644 --- a/series_store.go +++ b/series_store.go @@ -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) }