Skip to content

Commit

Permalink
debug checksum values in builder.close()
Browse files Browse the repository at this point in the history
  • Loading branch information
poyzannur committed Jan 10, 2024
1 parent 44b8174 commit e9d2d98
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/storage/bloom/v1/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package v1

import (
"bytes"
"encoding/binary"
"fmt"
"github.com/go-kit/kit/log/level"
util_log "github.com/grafana/loki/pkg/util/log"
"hash"
"io"
"sort"
Expand Down Expand Up @@ -166,6 +169,8 @@ func (b *BloomBlockBuilder) Close() (uint32, error) {

b.scratch.Reset()
b.scratch.PutUvarint(len(b.pages))
level.Info(util_log.Logger).Log("msg", "Closing bloom block, len pages", "pages", len(b.pages))

for _, h := range b.pages {
h.Encode(b.scratch)
}
Expand All @@ -175,10 +180,12 @@ func (b *BloomBlockBuilder) Close() (uint32, error) {
b.scratch.PutBE64(uint64(b.offset))

crc32Hash := Crc32HashPool.Get()

defer Crc32HashPool.Put(crc32Hash)
// wrap with final checksum
b.scratch.PutHash(crc32Hash)
_, err := b.writer.Write(b.scratch.Get())
level.Info(util_log.Logger).Log("msg", "Closing bloom block, checksum values", "hash from pool", crc32Hash.Sum32(), "after putHash", binary.BigEndian.Uint64(b.scratch.Get()))
if err != nil {
return 0, errors.Wrap(err, "writing bloom page headers")
}
Expand Down

0 comments on commit e9d2d98

Please sign in to comment.