Skip to content

Commit

Permalink
Proxy: Query goroutine leak when store.response-timeout is set
Browse files Browse the repository at this point in the history
time.AfterFunc() returns a time.Timer object whose C field is nil,
accroding to the documentation. A goroutine blocks forever on reading
from a `nil` channel, leading to a goroutine leak on random slow
queries.

Signed-off-by: Mikhail Nozdrachev <[email protected]>
  • Loading branch information
cincinnat committed Aug 9, 2024
1 parent dcadaae commit a4b9301
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/store/proxy_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ func newLazyRespSet(
var rerr error
// If timer is already stopped
if t != nil && !t.Stop() {
<-t.C // Drain the channel if it was already stopped.
if t.C != nil {
<-t.C // Drain the channel if it was already stopped.
}
rerr = errors.Wrapf(err, "failed to receive any data in %s from %s", l.frameTimeout, st)
} else {
rerr = errors.Wrapf(err, "receive series from %s", st)
Expand Down Expand Up @@ -614,7 +616,9 @@ func newEagerRespSet(
var rerr error
// If timer is already stopped
if t != nil && !t.Stop() {
<-t.C // Drain the channel if it was already stopped.
if t.C != nil {
<-t.C // Drain the channel if it was already stopped.
}
rerr = errors.Wrapf(err, "failed to receive any data in %s from %s", l.frameTimeout, storeName)
} else {
rerr = errors.Wrapf(err, "receive series from %s", storeName)
Expand Down

0 comments on commit a4b9301

Please sign in to comment.