Skip to content

chore: improve error messages and logging during shard opening#25314

Merged
gwossum merged 2 commits intomaster-1.xfrom
gw_shard_open_error_improvements
Sep 12, 2024
Merged

chore: improve error messages and logging during shard opening#25314
gwossum merged 2 commits intomaster-1.xfrom
gw_shard_open_error_improvements

Conversation

@gwossum
Copy link
Copy Markdown
Member

@gwossum gwossum commented Sep 11, 2024

No description provided.

@gwossum gwossum marked this pull request as ready for review September 11, 2024 20:54
Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

This will really help us debugging in the future. Nice work. I'd like to add (or in a few cases) restore the path/file to the error messages as a little more guidance for our debugging.

if f.IsDir() && strings.HasSuffix(f.Name(), ext) {
if err := os.RemoveAll(filepath.Join(e.path, f.Name())); err != nil {
return fmt.Errorf("error removing tmp snapshot directory %q: %s", f.Name(), err)
return fmt.Errorf("Engine.cleanup: error removing tmp snapshot directory: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep the file name in the message.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had that originally, but then I noticed that PathError contained the path so I removed the duplicate path. Upon closer inspection, these are loafers if you get a SyscallError, that doesn't include the path.

file, err := os.OpenFile(fn, os.O_RDONLY, 0666)
if err != nil {
return fmt.Errorf("error opening file %s: %v", fn, err)
return fmt.Errorf("FileStore.Open: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep the file name in the message


start := time.Now()
df, err := NewTSMReader(file, f.readerOptions...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unnecessary diff?

// If we are unable to read a TSM file then log the error.
if err != nil {
file.Close()
if cerr := file.Close(); cerr != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love this.

} else {
close(readerC)
return err
return fmt.Errorf("FileStore.Open: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add the directory name here.

tsdb/index.go Outdated
// nop, use default
} else if err != nil {
return nil, err
return nil, fmt.Errorf("NewIndex: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add the path in the message

Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

LGTM

@gwossum gwossum merged commit 23008e5 into master-1.x Sep 12, 2024
@gwossum gwossum deleted the gw_shard_open_error_improvements branch September 12, 2024 20:12
This was referenced Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants