fix: prevent an infinite loop in measurementFieldSetChangeMgr (#25155) (#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 https://github.com/influxdata/influxdb/issues/25151

(cherry picked from commit 176fca2138)

closes https://github.com/influxdata/influxdb/issues/25152
db-backport-25207
davidby-influx 2024-08-12 18:09:21 -07:00 committed by GitHub
parent 679426b9a5
commit 01a35eb79a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -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