Skip to content

Commit

Permalink
fix(tsi1): fix data race between appendEntry and FlushAndSync tsi1.(*…
Browse files Browse the repository at this point in the history
…LogFile) (influxdata#25182)

Extend lock lifespan to encompass the 
flushAndSync() call to avoid a race

closes influxdata#25181
  • Loading branch information
chengshiwen committed Jul 24, 2024
1 parent cf343f7 commit 8257737
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tsdb/index/tsi1/log_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,24 +1073,17 @@ func (f *LogFile) seriesSketches() (sketch, tSketch estimator.Sketch, err error)
return sketch, tSketch, nil
}

func (f *LogFile) ExecEntries(entries []LogEntry) error {
func (f *LogFile) Writes(entries []LogEntry) error {
f.mu.Lock()
defer f.mu.Unlock()

for i := range entries {
entry := &entries[i]
if err := f.appendEntry(entry); err != nil {
return err
}
f.execEntry(entry)
}
return nil
}

func (f *LogFile) Writes(entries []LogEntry) error {
if err := f.ExecEntries(entries); err != nil {
return err
}

// Flush buffer and sync to disk.
return f.FlushAndSync()
}
Expand Down

0 comments on commit 8257737

Please sign in to comment.