Ensure tmp files cleaned up when compaction disabled
parent
8550fabf89
commit
0748d28986
|
@ -748,6 +748,11 @@ func (c *Compactor) CompactFull(tsmFiles []string) ([]string, error) {
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
|
||||||
if !enabled {
|
if !enabled {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
if err := c.cleanupDisabledCompaction(tsmFiles); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errCompactionsDisabled
|
return nil, errCompactionsDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,6 +782,11 @@ func (c *Compactor) CompactFast(tsmFiles []string) ([]string, error) {
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
|
||||||
if !enabled {
|
if !enabled {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
if err := c.cleanupDisabledCompaction(tsmFiles); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return nil, errCompactionsDisabled
|
return nil, errCompactionsDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,6 +794,24 @@ func (c *Compactor) CompactFast(tsmFiles []string) ([]string, error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanupDisabledCompaction is responsible for cleaning up a compaction that
|
||||||
|
// was started, but then abandoned before the temporary files were dealt with.
|
||||||
|
func (c *Compactor) cleanupDisabledCompaction(tsmFiles []string) error {
|
||||||
|
for _, f := range tsmFiles {
|
||||||
|
files, err := filepath.Glob(filepath.Join(filepath.Dir(f), fmt.Sprintf("*.%s", CompactionTempExtension)))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error cleaning up compaction temp files: %s", err.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
|
// writeNewFiles writes from the iterator into new TSM files, rotating
|
||||||
// to a new file once it has reached the max TSM file size.
|
// to a new file once it has reached the max TSM file size.
|
||||||
func (c *Compactor) writeNewFiles(generation, sequence int, iter KeyIterator) ([]string, error) {
|
func (c *Compactor) writeNewFiles(generation, sequence int, iter KeyIterator) ([]string, error) {
|
||||||
|
|
Loading…
Reference in New Issue