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

Ensure tmp files cleaned up when compaction disabled #8562

Merged
merged 2 commits into from
Jul 5, 2017
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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
- [#8466](https://github.com/influxdata/influxdb/issues/8466): illumos build broken on syscall.Mmap
- [#8124](https://github.com/influxdata/influxdb/issues/8124): Prevent privileges on non-existent databases from being set.

## v1.3.0 [unreleased]
## v1.3.1 [unreleased]

### Bugfixes

- [#8559](https://github.com/influxdata/influxdb/issues/8559): Ensure temporary TSM files get cleaned up when compaction aborted.


## v1.3.0 [2017-06-21]

### Release Notes

Expand Down
17 changes: 17 additions & 0 deletions tsdb/engine/tsm1/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ func (c *Compactor) CompactFull(tsmFiles []string) ([]string, error) {
c.mu.RUnlock()

if !enabled {
if err := c.removeTmpFiles(files); err != nil {
return nil, err
}
return nil, errCompactionsDisabled
}

Expand Down Expand Up @@ -777,13 +780,27 @@ func (c *Compactor) CompactFast(tsmFiles []string) ([]string, error) {
c.mu.RUnlock()

if !enabled {
if err := c.removeTmpFiles(files); err != nil {
return nil, err
}
return nil, errCompactionsDisabled
}

return files, err

}

// removeTmpFiles is responsible for cleaning up a compaction that
// was started, but then abandoned before the temporary files were dealt with.
func (c *Compactor) removeTmpFiles(files []string) error {
for _, f := range files {
if err := os.Remove(f); err != nil {
return fmt.Errorf("error removing temp compaction file: %v", err)
}
}
return nil
}

// writeNewFiles writes from the iterator into new TSM files, rotating
// to a new file once it has reached the max TSM file size.
func (c *Compactor) writeNewFiles(generation, sequence int, iter KeyIterator) ([]string, error) {
Expand Down