Skip to content

Commit

Permalink
fix(tsi): sync index file before close (influxdata#21932)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeibo-duplicate authored and chengshiwen committed Aug 11, 2024
1 parent 4c4ac1f commit ed80518
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 @@ -1006,6 +1006,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 @@ -1151,9 +1156,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 ed80518

Please sign in to comment.