Skip to content

Commit

Permalink
Fix leaking tmp file when large compaction aborted
Browse files Browse the repository at this point in the history
If a large compaction was running and was aborted. It could would leave
some tmp files around for files that it had fully written.  The current
active file was cleaned up, but already completed ones would not.  This
would occur when a TSM file needed to rollover due to size.
  • Loading branch information
jwilder committed Aug 21, 2017
1 parent abf87f8 commit e265d15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

- [#8701](https://github.com/influxdata/influxdb/pull/8701): Fix drop measurement not dropping all data
- [#8713](https://github.com/influxdata/influxdb/issues/8713): Deadlock when dropping measurement and writing
- [#8726](https://github.com/influxdata/influxdb/pull/8726): Fix leaking tmp file when large compaction aborted

## v1.3.3 [unreleased]

Expand Down
6 changes: 6 additions & 0 deletions tsdb/engine/tsm1/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,12 @@ func (c *Compactor) writeNewFiles(generation, sequence int, iter KeyIterator) ([
// planner keeps track of which files are assigned to compaction plans now.
return nil, err
} else if err != nil {
// Remove any tmp files we already completed
for _, f := range files {
if err := os.RemoveAll(f); err != nil {
return nil, err
}
}
// We hit an error and didn't finish the compaction. Remove the temp file and abort.
if err := os.RemoveAll(fileName); err != nil {
return nil, err
Expand Down

0 comments on commit e265d15

Please sign in to comment.