@ -417,10 +417,6 @@ func (w *SegmentWAL) LogSeries(series []RefSeries) error {
tf . minSeries = s . Ref
}
}
if w . flushInterval <= 0 {
return errors . Wrap ( w . Sync ( ) , "sync" )
}
return nil
}
@ -447,10 +443,6 @@ func (w *SegmentWAL) LogSamples(samples []RefSample) error {
tf . maxTime = s . T
}
}
if w . flushInterval <= 0 {
return errors . Wrap ( w . Sync ( ) , "sync" )
}
return nil
}
@ -479,10 +471,6 @@ func (w *SegmentWAL) LogDeletes(stones []Stone) error {
}
}
}
if w . flushInterval <= 0 {
return errors . Wrap ( w . Sync ( ) , "sync" )
}
return nil
}
@ -537,19 +525,26 @@ func (w *SegmentWAL) createSegmentFile(name string) (*os.File, error) {
func ( w * SegmentWAL ) cut ( ) error {
// Sync current head to disk and close.
if hf := w . head ( ) ; hf != nil {
if err := w . sync ( ) ; err != nil {
if err := w . flush ( ) ; err != nil {
return err
}
// Finish last segment asynchronously to not block the WAL moving along
// in the new segment.
go func ( ) {
off , err := hf . Seek ( 0 , os . SEEK_CUR )
if err != nil {
return err
w . logger . Log ( "msg" , "finish old segment" , "segment" , hf . Name ( ) , "err" , err )
}
if err := hf . Truncate ( off ) ; err != nil {
return err
w . logger . Log ( "msg" , "finish old segment" , "segment" , hf . Name ( ) , "err" , err )
}
if err := hf . Sync ( ) ; err != nil {
w . logger . Log ( "msg" , "finish old segment" , "segment" , hf . Name ( ) , "err" , err )
}
if err := hf . Close ( ) ; err != nil {
return err
w . logger . Log ( "msg" , "finish old segment" , "segment" , hf . Name ( ) , "err" , err )
}
} ( )
}
p , _ , err := nextSequenceFile ( w . dirFile . Name ( ) )
@ -561,9 +556,11 @@ func (w *SegmentWAL) cut() error {
return err
}
go func ( ) {
if err = w . dirFile . Sync ( ) ; err != nil {
return err
w . logger . Log ( "msg" , "sync WAL directory" , "err" , err )
}
} ( )
w . files = append ( w . files , newSegmentFile ( f ) )