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: Do not close connection twice in DigestWithOptions #21659

Merged
merged 2 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
v1.9.3 [unreleased]
- [#21592](https://github.com/influxdata/influxdb/pull/21592): fix: avoid rewriting fields.idx unnecessarily
- [#21659](https://github.com/influxdata/influxdb/pull/21659): fix: do not close connection twice in DigestWithOptions

v1.9.2 [unreleased]
- [#21631](https://github.com/influxdata/influxdb/pull/21631): fix: group by returns multiple results per group in some circumstances
Expand Down
14 changes: 10 additions & 4 deletions tsdb/engine/tsm1/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type DigestOptions struct {

// DigestWithOptions writes a digest of dir to w using options to filter by
// time and key range.
func DigestWithOptions(dir string, files []string, opts DigestOptions, w io.WriteCloser) error {
func DigestWithOptions(dir string, files []string, opts DigestOptions, w io.WriteCloser) (err error) {
manifest, err := NewDigestManifest(dir, files)
if err != nil {
return err
Expand All @@ -31,7 +31,9 @@ func DigestWithOptions(dir string, files []string, opts DigestOptions, w io.Writ
tsmFiles := make([]TSMFile, 0, len(files))
defer func() {
for _, r := range tsmFiles {
r.Close()
if e := r.Close(); e != nil && err == nil {
err = e
}
}
}()

Expand All @@ -54,7 +56,11 @@ func DigestWithOptions(dir string, files []string, opts DigestOptions, w io.Writ
if err != nil {
return err
}
defer dw.Close()
defer func() {
if e := dw.Close(); e != nil && err == nil {
err = e
}
}()

// Write the manifest.
if err := dw.WriteManifest(manifest); err != nil {
Expand Down Expand Up @@ -106,7 +112,7 @@ func DigestWithOptions(dir string, files []string, opts DigestOptions, w io.Writ
return err
}
}
return dw.Close()
return nil
}

// Digest writes a digest of dir to w of a full shard dir.
Expand Down