Skip to content

Commit

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

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

(cherry picked from commit 031f394)

closes #25154
  • Loading branch information
davidby-influx authored Jul 16, 2024
1 parent e9e0f74 commit 8e0d754
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 8e0d754

Please sign in to comment.