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: ignore empty index error deleting last measurement #25037

Merged
merged 2 commits into from
Jun 4, 2024

Conversation

davidby-influx
Copy link
Contributor

An empty index is appropriate when deleting the last measurement. Also clean up error handling, avoid
duplicate calls to Close.

closes #9929

An empty index is appropriate when deleting the last
measurement.  Also clean up error handling, avoid
duplicate calls to Close.

closes #9929
Copy link
Member

@gwossum gwossum left a 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.

Comment on lines 160 to 163
} 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)
Copy link
Member

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?

Comment on lines +161 to +169
// 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
}
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@gwossum gwossum left a comment

Choose a reason for hiding this comment

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

LGTM

@davidby-influx davidby-influx merged commit b09e4b7 into master-1.x Jun 4, 2024
9 checks passed
@davidby-influx davidby-influx deleted the DSB_delete_tsm branch June 4, 2024 19:30
@davidby-influx davidby-influx linked an issue Jun 4, 2024 that may be closed by this pull request
davidby-influx added a commit that referenced this pull request Jun 4, 2024
An empty index is appropriate when deleting the last
measurement.  Also clean up error handling, avoid
duplicate calls to Close.

closes #9929

(cherry picked from commit b09e4b7)

closes #25038
davidby-influx added a commit that referenced this pull request Jun 4, 2024
)

An empty index is appropriate when deleting the last
measurement.  Also clean up error handling, avoid
duplicate calls to Close.

closes #9929

(cherry picked from commit b09e4b7)

closes #25038
chengshiwen pushed a commit to chengshiwen/influxdb that referenced this pull request Aug 27, 2024
…5037)

An empty index is appropriate when deleting the last
measurement.  Also clean up error handling, avoid
duplicate calls to Close.

closes influxdata#9929
chengshiwen pushed a commit to chengshiwen/influxdb that referenced this pull request Aug 28, 2024
…5037)

An empty index is appropriate when deleting the last
measurement.  Also clean up error handling, avoid
duplicate calls to Close.

closes influxdata#9929
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.

influx_inspect deletetsm: Can't delete last measurement
2 participants