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) #21662

Merged
merged 2 commits into from
Jun 10, 2021
Merged
Changes from 1 commit
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
Next Next commit
fix: Do not close connection twice in DigestWithOptions (#21659)
tsm1.DigestWithOptions closes its network connection
twice. This may cause broken pipe errors on concurrent
invocations of the same procedure, by closing a reused
i/o descriptor. This fix also captures errors from TSM
file closures, which were previously ignored.

Closes #21656

(cherry picked from commit bce6553)
  • Loading branch information
davidby-influx committed Jun 10, 2021
commit 59a2002fa2715bc786c725e8982af7d89fa1815c
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