Skip to content

Commit d7d4ddf

Browse files
committed
Filter empty series client side too.
Signed-off-by: Goutham Veeramachaneni <[email protected]>
1 parent 0378daf commit d7d4ddf

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pkg/querier/ingester_streaming_queryable.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (i ingesterQueryable) Get(ctx context.Context, from, through model.Time, ma
5454

5555
chunks := make([]chunk.Chunk, 0, len(results))
5656
for _, result := range results {
57+
// Sometimes the ingester can send series that have no data.
58+
if len(result.Chunks) == 0 {
59+
continue
60+
}
61+
5762
metric := client.FromLabelAdaptersToMetric(result.Labels)
5863
cs, err := chunkcompat.FromChunks(userID, metric, result.Chunks)
5964
if err != nil {
@@ -89,6 +94,11 @@ func (q *ingesterStreamingQuerier) Select(sp *storage.SelectParams, matchers ...
8994

9095
serieses := make([]storage.Series, 0, len(results))
9196
for _, result := range results {
97+
// Sometimes the ingester can send series that have no data.
98+
if len(result.Chunks) == 0 {
99+
continue
100+
}
101+
92102
chunks, err := chunkcompat.FromChunks(userID, nil, result.Chunks)
93103
if err != nil {
94104
return nil, nil, promql.ErrStorage{Err: err}

pkg/querier/ingester_streaming_queryable_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,41 @@ import (
44
"context"
55
"testing"
66

7+
"github.com/prometheus/common/model"
78
"github.com/prometheus/prometheus/pkg/labels"
89
"github.com/stretchr/testify/require"
910

11+
"github.com/cortexproject/cortex/pkg/chunk"
12+
"github.com/cortexproject/cortex/pkg/chunk/encoding"
1013
"github.com/cortexproject/cortex/pkg/ingester/client"
14+
"github.com/cortexproject/cortex/pkg/util/chunkcompat"
1115
"github.com/weaveworks/common/user"
1216
)
1317

1418
func TestIngesterStreaming(t *testing.T) {
19+
// We need to make sure that there is atleast one chunk present,
20+
// else no series will be selected.
21+
promChunk, err := encoding.NewForEncoding(encoding.Bigchunk)
22+
require.NoError(t, err)
23+
24+
clientChunks, err := chunkcompat.ToChunks([]chunk.Chunk{
25+
chunk.NewChunk("", 0, nil, promChunk, model.Earliest, model.Earliest),
26+
})
27+
require.NoError(t, err)
28+
1529
d := &mockDistributor{
1630
r: []client.TimeSeriesChunk{
1731
{
1832
Labels: []client.LabelAdapter{
1933
{Name: "bar", Value: "baz"},
2034
},
35+
Chunks: clientChunks,
2136
},
2237
{
2338
Labels: []client.LabelAdapter{
2439
{Name: "foo", Value: "bar"},
2540
},
41+
Chunks: clientChunks,
2642
},
2743
},
2844
}

0 commit comments

Comments
 (0)