Merge pull request #6082 from influxdata/jw-tsm

Fix partially written TSM files
pull/6073/head
Jason Wilder 2016-03-21 15:42:27 -06:00
commit ee2f21e76f
4 changed files with 19 additions and 3 deletions

View File

@ -90,6 +90,7 @@ There were some important breaking changes in this release. Here's a list of the
- [#5965](https://github.com/influxdata/influxdb/issues/5965): InfluxDB panic crashes while parsing "-" as Float
- [#5835](https://github.com/influxdata/influxdb/issues/5835): Make CREATE USER default to IF NOT EXISTS
- [#6042](https://github.com/influxdata/influxdb/issues/6042): CreateDatabase failure on Windows, regression from v0.11.0 RC @mvadu
- [#5889](https://github.com/influxdata/influxdb/issues/5889): Fix writing partial TSM index when flush file fails
## v0.10.3 [2016-03-09]

View File

@ -538,7 +538,7 @@ func (c *Compactor) writeNewFiles(generation, sequence int, iter KeyIterator) ([
return files, nil
}
func (c *Compactor) write(path string, iter KeyIterator) error {
func (c *Compactor) write(path string, iter KeyIterator) (err error) {
if _, err := os.Stat(path); !os.IsNotExist(err) {
return fmt.Errorf("%v already file exists. aborting", path)
}
@ -553,7 +553,12 @@ func (c *Compactor) write(path string, iter KeyIterator) error {
if err != nil {
return err
}
defer w.Close()
defer func() {
closeErr := w.Close()
if err == nil {
err = closeErr
}
}()
for iter.Next() {
select {
@ -590,7 +595,6 @@ func (c *Compactor) write(path string, iter KeyIterator) error {
if err := w.WriteIndex(); err != nil {
return err
}
return nil
}

View File

@ -436,6 +436,10 @@ func (f *FileStore) Replace(oldFiles, newFiles []string) error {
}
}
if err := syncDir(f.dir); err != nil {
return err
}
f.files = active
sort.Sort(tsmReaders(f.files))

View File

@ -70,6 +70,7 @@ import (
"hash/crc32"
"io"
"math"
"os"
"sort"
"sync"
"time"
@ -639,6 +640,12 @@ func (t *tsmWriter) Close() error {
return err
}
if f, ok := t.wrapped.(*os.File); ok {
if err := f.Sync(); err != nil {
return err
}
}
if c, ok := t.wrapped.(io.Closer); ok {
return c.Close()
}