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 #25153
  • Loading branch information
davidby-influx committed Jul 12, 2024
1 parent c2b3e38 commit f4c6851
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 @@ -2276,10 +2276,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 f4c6851

Please sign in to comment.