From 7b20b1db38857ee69abe6cb1e7e3c67ef4b96fe8 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Thu, 31 Aug 2023 14:45:25 +0200 Subject: [PATCH] Store: fix postings reader short reads (#6684) bufio.Reader can return less bytes than needed. Go documentation suggests to use io.ReadFull Signed-off-by: Michael Hoffmann --- pkg/store/bucket.go | 2 +- pkg/store/postings.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index ac18f9d967..0d780fc2c7 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -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 diff --git a/pkg/store/postings.go b/pkg/store/postings.go index 28fbf0cf01..e44dfbe66c 100644 --- a/pkg/store/postings.go +++ b/pkg/store/postings.go @@ -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") }