Skip to content

Commit

Permalink
fix: prevent an infinite loop in measurementFieldSetChangeMgr (#25155) (
Browse files Browse the repository at this point in the history
#25241)

The measurementFieldSetChangeMgr has a possibly infinite loop
if the writeRequests channel is closed while in the inner
loop to consolidate write requests. We need to check for ok
on channel receive and exit the loop when ok is false.

closes #25151

(cherry picked from commit 176fca2)

closes #25152
  • Loading branch information
davidby-influx authored Aug 13, 2024
1 parent 679426b commit 01a35eb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tsdb/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2020,10 +2020,12 @@ func (fscm *measurementFieldSetChangeMgr) appendToChangesFile(first writeRequest
// requests
for {
select {
case wr := <-fscm.writeRequests:
changes = append(changes, wr.changes)
errorChannels = append(errorChannels, wr.errorReturn)
continue
case wr, ok := <-fscm.writeRequests:
if ok {
changes = append(changes, wr.changes)
errorChannels = append(errorChannels, wr.errorReturn)
continue
}
default:
}
break
Expand Down

0 comments on commit 01a35eb

Please sign in to comment.