From 7a66d9035dbb9466178ae3a78cf15159e8fcfdd9 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Tue, 9 Jun 2020 08:58:55 +0200 Subject: [PATCH 1/3] Fix Redis cache error when a query has no chunks to lookup Signed-off-by: Marco Pracucci --- pkg/chunk/composite_store.go | 5 +++++ pkg/chunk/series_store.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/chunk/composite_store.go b/pkg/chunk/composite_store.go index 659ef65edf6..46e055fcb13 100644 --- a/pkg/chunk/composite_store.go +++ b/pkg/chunk/composite_store.go @@ -162,6 +162,11 @@ func (c compositeStore) GetChunkRefs(ctx context.Context, userID string, from, t return err } + // Skip it if there are no chunks. + if len(ids) == 0 { + return nil + } + chunkIDs = append(chunkIDs, ids...) fetchers = append(fetchers, fetcher...) return nil diff --git a/pkg/chunk/series_store.go b/pkg/chunk/series_store.go index 74f3f67b57f..4928ca9b964 100644 --- a/pkg/chunk/series_store.go +++ b/pkg/chunk/series_store.go @@ -182,6 +182,11 @@ func (c *seriesStore) GetChunkRefs(ctx context.Context, userID string, from, thr level.Debug(log).Log("chunks-post-filtering", len(chunks)) chunksPerQuery.Observe(float64(len(chunks))) + // We should return an empty chunks slice if there are no chunks. + if len(chunks) == 0 { + return [][]Chunk{}, []*Fetcher{}, nil + } + return [][]Chunk{chunks}, []*Fetcher{c.baseStore.Fetcher}, nil } From a38f82a0d51017111b8cc45310580df763deafed Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Tue, 9 Jun 2020 09:02:37 +0200 Subject: [PATCH 2/3] Added CHANGELOG entry Signed-off-by: Marco Pracucci --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf84c8f922..3d7c8bef61d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -121,6 +121,7 @@ * [BUGFIX] Experimental TSDB: when the querier receives a `/series` request with a time range older than the data stored in the ingester, it now ignores the requested time range and returns known series anyway instead of returning an empty response. This aligns the behaviour with the chunks storage. #2617 * [BUGFIX] Cassandra: fixed an edge case leading to an invalid CQL query when querying the index on a Cassandra store. #2639 * [BUGFIX] Ingester: increment series per metric when recovering from WAL or transfer. #2674 +* [BUGFIX] Fixed `wrong number of arguments for 'mget' command` Redis error when a query has no chunks to lookup from storage. #2700 ## 1.1.0 / 2020-05-21 From e46d1de7189def6748fe959c5aea16d1b53ea469 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Thu, 11 Jun 2020 10:06:39 +0200 Subject: [PATCH 3/3] Fixed another case leading to 'wrong number of arguments for 'mget' command' Signed-off-by: Marco Pracucci --- pkg/chunk/chunk_store.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/chunk/chunk_store.go b/pkg/chunk/chunk_store.go index aa556b5d077..bd69eedeea3 100644 --- a/pkg/chunk/chunk_store.go +++ b/pkg/chunk/chunk_store.go @@ -505,6 +505,11 @@ func (c *baseStore) lookupEntriesByQueries(ctx context.Context, queries []IndexQ log, ctx := spanlogger.New(ctx, "store.lookupEntriesByQueries") defer log.Span.Finish() + // Nothing to do if there are no queries. + if len(queries) == 0 { + return nil, nil + } + var lock sync.Mutex var entries []IndexEntry err := c.index.QueryPages(ctx, queries, func(query IndexQuery, resp ReadBatch) bool { @@ -527,7 +532,12 @@ func (c *baseStore) lookupEntriesByQueries(ctx context.Context, queries []IndexQ return entries, err } -func (c *baseStore) parseIndexEntries(ctx context.Context, entries []IndexEntry, matcher *labels.Matcher) ([]string, error) { +func (c *baseStore) parseIndexEntries(_ context.Context, entries []IndexEntry, matcher *labels.Matcher) ([]string, error) { + // Nothing to do if there are no entries. + if len(entries) == 0 { + return nil, nil + } + result := make([]string, 0, len(entries)) for _, entry := range entries { chunkKey, labelValue, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value)