Merge pull request #5434 from runner-mei/tsm_tombstone_windows

fix TSMReader.Delete() and all unit tests is pass in the windows
pull/5525/merge
Jason Wilder 2016-02-04 16:27:26 -07:00
commit 28ae8b6fe0
4 changed files with 28 additions and 9 deletions

View File

@ -433,7 +433,9 @@ func TestTSMKeyIterator_MultipleKeysDeleted(t *testing.T) {
}
r1 := MustTSMReader(dir, 1, points1)
r1.Delete([]string{"cpu,host=A#!~#value"})
if e := r1.Delete([]string{"cpu,host=A#!~#value"}); nil != e {
t.Fatal(e)
}
v2 := tsm1.NewValue(time.Unix(1, 0), float64(1))
v3 := tsm1.NewValue(time.Unix(1, 0), float64(1))

View File

@ -0,0 +1,15 @@
// +build !windows
package tsm1
import "os"
func syncDir(dirName string) error {
// fsync the dir to flush the rename
dir, err := os.OpenFile(dirName, os.O_RDONLY, os.ModeDir)
if err != nil {
return err
}
defer dir.Close()
return dir.Sync()
}

View File

@ -0,0 +1,5 @@
package tsm1
func syncDir(dirName string) error {
return nil
}

View File

@ -94,17 +94,14 @@ func (t *Tombstoner) writeTombstone(tombstones []string) error {
return err
}
if err := os.Rename(tmp.Name(), t.tombstonePath()); err != nil {
tmpFilename := tmp.Name()
tmp.Close()
if err := os.Rename(tmpFilename, t.tombstonePath()); err != nil {
return err
}
// fsync the dir to flush the rename
dir, err := os.OpenFile(filepath.Dir(t.tombstonePath()), os.O_RDONLY, os.ModeDir)
if err != nil {
return err
}
defer dir.Close()
return dir.Sync()
return syncDir(filepath.Dir(t.tombstonePath()))
}
func (t *Tombstoner) readTombstone() ([]string, error) {