Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race when stopping chunks memcached client #4511

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/chunk/cache/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ func NewMemcached(cfg MemcachedConfig, client MemcachedClient, name string, reg
batchID: input.batchID,
}
res.found, res.bufs, res.missed = c.fetch(input.ctx, input.keys)
input.resultCh <- res
// No-one will be reading from resultCh if we were asked to quit
// during the fetch, so check again before writing to it.
select {
case <-c.quit:
return
case input.resultCh <- res:
}
}
}
}()
Expand Down Expand Up @@ -214,7 +220,6 @@ loopResults:
results[result.batchID] = result
}
}
close(resultsCh)

for _, result := range results {
if result == nil {
Expand Down