Skip to content

Commit

Permalink
Calculating hashes by default
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <[email protected]>
  • Loading branch information
pedro-stanaka committed Sep 26, 2022
1 parent 4faad90 commit c4eb864
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 145 deletions.
7 changes: 6 additions & 1 deletion pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const (
labelDecode = "decode"

minBlockSyncConcurrency = 1

enableChunkHashCalculation = true
)

var (
Expand Down Expand Up @@ -314,6 +316,8 @@ type BucketStore struct {

// Enables hints in the Series() response.
enableSeriesResponseHints bool

enableChunkHashCalculation bool
}

func (s *BucketStore) validate() error {
Expand Down Expand Up @@ -425,6 +429,7 @@ func NewBucketStore(
enableCompatibilityLabel: enableCompatibilityLabel,
postingOffsetsInMemSampling: postingOffsetsInMemSampling,
enableSeriesResponseHints: enableSeriesResponseHints,
enableChunkHashCalculation: enableChunkHashCalculation,
}

for _, option := range options {
Expand Down Expand Up @@ -1104,7 +1109,7 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
req.MinTime, req.MaxTime,
req.Aggregates,
shardMatcher,
req.CalculateChunkChecksums,
s.enableChunkHashCalculation,
)
if err != nil {
return errors.Wrapf(err, "fetch series for block %s", b.meta.ULID)
Expand Down
22 changes: 2 additions & 20 deletions pkg/store/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,8 @@ func TestPrometheusStore_Series_ChunkHashCalculation_Integration(t *testing.T) {
srv := newStoreSeriesServer(ctx)

testutil.Ok(t, proxy.Series(&storepb.SeriesRequest{
MinTime: baseT + 101,
MaxTime: baseT + 300,
CalculateChunkChecksums: true,
MinTime: baseT + 101,
MaxTime: baseT + 300,
Matchers: []storepb.LabelMatcher{
{Name: "a", Value: "b"},
{Type: storepb.LabelMatcher_EQ, Name: "region", Value: "eu-west"},
Expand All @@ -480,23 +479,6 @@ func TestPrometheusStore_Series_ChunkHashCalculation_Integration(t *testing.T) {
want := xxhash.Sum64(chunk.Raw.Data)
testutil.Equals(t, want, got)
}

// by default do not calculate the checksums
testutil.Ok(t, proxy.Series(&storepb.SeriesRequest{
MinTime: baseT + 101,
MaxTime: baseT + 300,
Matchers: []storepb.LabelMatcher{
{Name: "a", Value: "b"},
{Type: storepb.LabelMatcher_EQ, Name: "region", Value: "eu-west"},
},
CalculateChunkChecksums: false,
}, srv))
testutil.Equals(t, 2, len(srv.SeriesSet))
for _, chunk := range srv.SeriesSet[1].Chunks {
got := chunk.Raw.Hash
want := uint64(0)
testutil.Equals(t, want, got)
}
}

func TestPrometheusStore_Info(t *testing.T) {
Expand Down
Loading

0 comments on commit c4eb864

Please sign in to comment.