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: restore in-memory Manifest on write error #23552

Merged
merged 5 commits into from
Jul 20, 2022

Conversation

davidby-influx
Copy link
Contributor

@davidby-influx davidby-influx commented Jul 18, 2022

Do not update the FileSet or activeLogFile field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

@davidby-influx davidby-influx requested a review from lesam July 18, 2022 17:05
@davidby-influx davidby-influx self-assigned this Jul 18, 2022
@davidby-influx davidby-influx marked this pull request as ready for review July 18, 2022 23:05
lesam
lesam previously approved these changes Jul 20, 2022
tsdb/index/tsi1/partition.go Show resolved Hide resolved
tsdb/index/tsi1/partition_test.go Outdated Show resolved Hide resolved
Also improved test error messages per review comments
tsdb/index/tsi1/partition.go Outdated Show resolved Hide resolved
tsdb/index/tsi1/partition.go Outdated Show resolved Hide resolved
tsdb/index/tsi1/partition_test.go Outdated Show resolved Hide resolved
tsdb/index/tsi1/partition_test.go Outdated Show resolved Hide resolved
if err != nil {
// TODO: Close index if write fails.
p.logger.Error("manifest file write failed compacting index", zap.String("path", p.ManifestPath()), zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

p.logger vs log here - we should be consistent about which one to log with.

if err != nil {
// TODO: Close index if write fails.
p.logger.Error("manifest file write failed compacting index", zap.String("path", p.ManifestPath()), zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

We should always either return an error (with appropriate context for the caller) or log the error, but not both. Otherwise we end up logging errors at every level of the call stack.

We can avoid being religious about that for now if necessary, but any time we log an error and then return the error is a code smell for me.

if err != nil {
// TODO: Close index if write fails.
p.logger.Error("manifest file write failed compacting log file", zap.String("path", p.ManifestPath()), zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

p.logger.Error here vs log.Error below.

@davidby-influx davidby-influx merged commit a8732dc into master-1.x Jul 20, 2022
@davidby-influx davidby-influx deleted the DSB_manifest_lock branch July 20, 2022 19:59
davidby-influx added a commit that referenced this pull request Jul 20, 2022
Do not update the `FileSet` or `activeLogFile` field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

(cherry picked from commit a8732dc)

closes #23555
davidby-influx added a commit that referenced this pull request Jul 20, 2022
Do not update the `FileSet` or `activeLogFile` field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

(cherry picked from commit a8732dc)

closes #23555
davidby-influx added a commit that referenced this pull request Jul 20, 2022
Do not update the `FileSet` or `activeLogFile` field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

(cherry picked from commit a8732dc)

closes #23554
davidby-influx added a commit that referenced this pull request Jul 20, 2022
Do not update the `FileSet` or `activeLogFile` field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

(cherry picked from commit a8732dc)

closes #23555
davidby-influx added a commit that referenced this pull request Jul 25, 2022
Do not update the `FileSet` or `activeLogFile` field in the in-memory
Partition structure if the Manifest file is not correctly saved to
the disk.

closes #23553

(cherry picked from commit a8732dc)

closes #23554
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants