Skip to content

Commit

Permalink
fix: prevent an infinite loop in measurementFieldSetChangeMgr (#25155)
Browse files Browse the repository at this point in the history
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 committed Aug 12, 2024
1 parent c7a591b commit bdebce6
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 bdebce6

Please sign in to comment.