Skip to content

Commit

Permalink
Store: fix postings reader short reads (#6684)
Browse files Browse the repository at this point in the history
bufio.Reader can return less bytes than needed. Go documentation
suggests to use io.ReadFull

Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann authored Aug 31, 2023
1 parent e0126c7 commit 7b20b1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ func (r *bucketIndexReader) fetchPostings(ctx context.Context, keys []labels.Lab
r.stats.PostingsFetchDurationSum += time.Since(begin)
r.mtx.Unlock()

if rdr.Error() != nil {
if err := rdr.Error(); err != nil {
return errors.Wrap(err, "reading postings")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/postings.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newPostingsReaderBuilder(ctx context.Context, r *bufio.Reader, postings []p
}

func getInt32(r io.Reader, buf []byte) (uint32, error) {
read, err := r.Read(buf)
read, err := io.ReadFull(r, buf)
if err != nil {
return 0, errors.Wrap(err, "reading")
}
Expand Down

0 comments on commit 7b20b1d

Please sign in to comment.