Skip to content

Commit

Permalink
fix(tsi): sync index file before close (#22927)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5fd1b29)

Co-authored-by: lifeibo <[email protected]>
  • Loading branch information
lesam and lifeibo-duplicate authored Nov 24, 2021
1 parent 9308b65 commit 799d349
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tsdb/index/tsi1/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,11 @@ func (p *Partition) compactToLevel(files []*IndexFile, level int, interrupt <-ch
return
}

if err = f.Sync(); err != nil {
log.Error("Error sync index file", zap.Error(err))
return
}

// Close file.
if err := f.Close(); err != nil {
log.Error("Error closing index file", zap.Error(err))
Expand Down Expand Up @@ -1226,9 +1231,14 @@ func (p *Partition) compactLogFile(logFile *LogFile) {
return
}

if err = f.Sync(); err != nil {
log.Error("Cannot sync index file", zap.Error(err))
return
}

// Close file.
if err := f.Close(); err != nil {
log.Error("Cannot close log file", zap.Error(err))
log.Error("Cannot close index file", zap.Error(err))
return
}

Expand Down

0 comments on commit 799d349

Please sign in to comment.