From c8a16bb4d0d96a3602b88bb59045ee5db700782b Mon Sep 17 00:00:00 2001 From: Ben Clive Date: Mon, 12 Aug 2024 16:26:35 +0100 Subject: [PATCH 1/3] Better errors --- pkg/querier-rf1/wal/chunks.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/querier-rf1/wal/chunks.go b/pkg/querier-rf1/wal/chunks.go index 76070006aff40..d9b1e66dfcb4a 100644 --- a/pkg/querier-rf1/wal/chunks.go +++ b/pkg/querier-rf1/wal/chunks.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" + "github.com/pkg/errors" "github.com/prometheus/prometheus/model/labels" "golang.org/x/sync/errgroup" @@ -309,14 +310,14 @@ func readChunkData(ctx context.Context, storage BlockStorage, chunk ChunkData) ( // together. reader, err := storage.GetObjectRange(ctx, wal.Dir+chunk.id, int64(offset), int64(size)) if err != nil { - return nil, err + return nil, errors.Wrap(err, "could not get range reader for "+chunk.id) } defer reader.Close() data := make([]byte, size) _, err = reader.Read(data) if err != nil { - return nil, err + return nil, errors.Wrap(err, "could not read socket for "+chunk.id) } return data, nil From bacd16214cd317d15798093cc51032be5b844b06 Mon Sep 17 00:00:00 2001 From: Ben Clive Date: Mon, 12 Aug 2024 17:55:49 +0100 Subject: [PATCH 2/3] accept EOF --- pkg/querier-rf1/wal/chunks.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/querier-rf1/wal/chunks.go b/pkg/querier-rf1/wal/chunks.go index d9b1e66dfcb4a..1745908f7983a 100644 --- a/pkg/querier-rf1/wal/chunks.go +++ b/pkg/querier-rf1/wal/chunks.go @@ -3,6 +3,7 @@ package wal import ( "context" "fmt" + "io" "sort" "github.com/pkg/errors" @@ -316,7 +317,7 @@ func readChunkData(ctx context.Context, storage BlockStorage, chunk ChunkData) ( data := make([]byte, size) _, err = reader.Read(data) - if err != nil { + if err != nil && err != io.EOF { return nil, errors.Wrap(err, "could not read socket for "+chunk.id) } From 46f93e65e14e35a3b1f2170f78b0efa70c501484 Mon Sep 17 00:00:00 2001 From: Ben Clive Date: Wed, 14 Aug 2024 14:15:57 +0100 Subject: [PATCH 3/3] PR fixes --- pkg/querier-rf1/wal/chunks.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/querier-rf1/wal/chunks.go b/pkg/querier-rf1/wal/chunks.go index 1745908f7983a..15f49836b5b2a 100644 --- a/pkg/querier-rf1/wal/chunks.go +++ b/pkg/querier-rf1/wal/chunks.go @@ -2,11 +2,11 @@ package wal import ( "context" + "errors" "fmt" "io" "sort" - "github.com/pkg/errors" "github.com/prometheus/prometheus/model/labels" "golang.org/x/sync/errgroup" @@ -311,14 +311,14 @@ func readChunkData(ctx context.Context, storage BlockStorage, chunk ChunkData) ( // together. reader, err := storage.GetObjectRange(ctx, wal.Dir+chunk.id, int64(offset), int64(size)) if err != nil { - return nil, errors.Wrap(err, "could not get range reader for "+chunk.id) + return nil, fmt.Errorf("could not get range reader for %s: %w", chunk.id, err) } defer reader.Close() data := make([]byte, size) _, err = reader.Read(data) - if err != nil && err != io.EOF { - return nil, errors.Wrap(err, "could not read socket for "+chunk.id) + if err != nil && !errors.Is(err, io.EOF) { + return nil, fmt.Errorf("could not read socket for %s: %w", chunk.id, err) } return data, nil