diff --git a/pkg/store/bucket_test.go b/pkg/store/bucket_test.go index 5b15bb6899..bdaecc673b 100644 --- a/pkg/store/bucket_test.go +++ b/pkg/store/bucket_test.go @@ -2212,10 +2212,6 @@ func TestSeries_ChuncksHaveHashRepresentation(t *testing.T) { name: "calculate checksum", calculateChecksum: true, }, - { - name: "do not calculate checksum", - calculateChecksum: false, - }, } for _, tc := range testCases { @@ -2226,7 +2222,6 @@ func TestSeries_ChuncksHaveHashRepresentation(t *testing.T) { Matchers: []storepb.LabelMatcher{ {Type: storepb.LabelMatcher_EQ, Name: "__name__", Value: "test"}, }, - CalculateChunkChecksums: tc.calculateChecksum, } srv := newStoreSeriesServer(context.Background()) diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 7c7efc9e51..b4546c7d05 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -234,13 +234,13 @@ func (p *PrometheusStore) Series(r *storepb.SeriesRequest, s storepb.Store_Serie // remote read. contentType := httpResp.Header.Get("Content-Type") if strings.HasPrefix(contentType, "application/x-protobuf") { - return p.handleSampledPrometheusResponse(s, httpResp, queryPrometheusSpan, extLset, r.CalculateChunkChecksums) + return p.handleSampledPrometheusResponse(s, httpResp, queryPrometheusSpan, extLset, enableChunkHashCalculation) } if !strings.HasPrefix(contentType, "application/x-streamed-protobuf; proto=prometheus.ChunkedReadResponse") { return errors.Errorf("not supported remote read content type: %s", contentType) } - return p.handleStreamedPrometheusResponse(s, shardMatcher, httpResp, queryPrometheusSpan, extLset, r.CalculateChunkChecksums) + return p.handleStreamedPrometheusResponse(s, shardMatcher, httpResp, queryPrometheusSpan, extLset, enableChunkHashCalculation) } func (p *PrometheusStore) queryPrometheus(s storepb.Store_SeriesServer, r *storepb.SeriesRequest) error { @@ -294,7 +294,7 @@ func (p *PrometheusStore) queryPrometheus(s storepb.Store_SeriesServer, r *store Samples: prompb.SamplesFromSamplePairs(vector.Values), } - chks, err := p.chunkSamples(series, MaxSamplesPerChunk, r.CalculateChunkChecksums) + chks, err := p.chunkSamples(series, MaxSamplesPerChunk, enableChunkHashCalculation) if err != nil { return err } diff --git a/pkg/store/storepb/testutil/series.go b/pkg/store/storepb/testutil/series.go index f3d2fad338..ce6d14ee31 100644 --- a/pkg/store/storepb/testutil/series.go +++ b/pkg/store/storepb/testutil/series.go @@ -6,6 +6,7 @@ package storetestutil import ( "context" "fmt" + "github.com/cespare/xxhash" "math" "math/rand" "os" @@ -140,7 +141,7 @@ func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head, expected[len(expected)-1].Chunks = append(expected[len(expected)-1].Chunks, storepb.AggrChunk{ MinTime: c.MinTime, MaxTime: c.MaxTime, - Raw: &storepb.Chunk{Type: storepb.Chunk_XOR, Data: chEnc.Bytes()}, + Raw: &storepb.Chunk{Type: storepb.Chunk_XOR, Data: chEnc.Bytes(), Hash: xxhash.Sum64(chEnc.Bytes())}, }) } } diff --git a/pkg/store/tsdb_test.go b/pkg/store/tsdb_test.go index 4037050cde..9fdaed7664 100644 --- a/pkg/store/tsdb_test.go +++ b/pkg/store/tsdb_test.go @@ -92,25 +92,11 @@ func TestTSDBStore_Series_ChunkChecksum(t *testing.T) { {Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"}, }, } - err = tsdbStore.Series(req, srv) - testutil.Ok(t, err) - - for _, chk := range srv.SeriesSet[0].Chunks { - testutil.Equals(t, uint64(0), chk.Raw.Hash) - } - - req = &storepb.SeriesRequest{ - MinTime: 1, - MaxTime: 3, - Matchers: []storepb.LabelMatcher{ - {Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"}, - }, - } err = tsdbStore.Series(req, srv) testutil.Ok(t, err) - for _, chk := range srv.SeriesSet[1].Chunks { + for _, chk := range srv.SeriesSet[0].Chunks { want := xxhash.Sum64(chk.Raw.Data) testutil.Equals(t, want, chk.Raw.Hash) }