-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: ignore empty index error deleting last measurement #25037
Conversation
An empty index is appropriate when deleting the last measurement. Also clean up error handling, avoid duplicate calls to Close. closes #9929
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question about cleaning up if errors occur.
} else if err = os.RemoveAll(path); err != nil { | ||
return fmt.Errorf("cannot remove %s: %w", path, err) | ||
} else if err = os.RemoveAll(outputPath); err != nil { | ||
return fmt.Errorf("cannot remove temporary file %s: %w", outputPath, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't remove path
, then we won't try to remove outputPath
? Should we be trying to delete outputPath
even if we fail to remove path
?
// Empty TSM file of size == 0, remove it | ||
if err = os.RemoveAll(path); err != nil { | ||
err = fmt.Errorf("cannot remove %s: %w", path, err) | ||
} | ||
if err2 := os.RemoveAll(outputPath); err2 != nil && err == nil { | ||
return fmt.Errorf("cannot remove temporary file %s: %w", outputPath, err) | ||
} else { | ||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably would have preferred collecting the errors in a list and then calling errors.Join
, but this is just as viable, especially for influx_inspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would have been better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…5037) An empty index is appropriate when deleting the last measurement. Also clean up error handling, avoid duplicate calls to Close. closes influxdata#9929
…5037) An empty index is appropriate when deleting the last measurement. Also clean up error handling, avoid duplicate calls to Close. closes influxdata#9929
An empty index is appropriate when deleting the last measurement. Also clean up error handling, avoid
duplicate calls to Close.
closes #9929