Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle EOF when reading from some obj stores #13868

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/querier-rf1/wal/chunks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package wal
import (
"context"
"fmt"
"io"
"sort"

"github.com/pkg/errors"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"github.com/pkg/errors"
"errors"

"github.com/prometheus/prometheus/model/labels"
"golang.org/x/sync/errgroup"

Expand Down Expand Up @@ -309,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, err
return nil, errors.Wrap(err, "could not get range reader for "+chunk.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
return nil, err
if err != nil && err != io.EOF {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil && err != io.EOF {
if err != nil && !errors.Is(err, io.EOF) {

return nil, errors.Wrap(err, "could not read socket for "+chunk.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, errors.Wrap(err, "could not read socket for "+chunk.id)
return nil, fmt.Errorf("could not read socket for %s: %w", chunk.id, err)

}

return data, nil
Expand Down
Loading