mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/logstorage: skip scheduled work when stopCh is closed
This saves CPU time
This commit is contained in:
parent
e42b9d26a9
commit
ffdafc32c6
1 changed files with 7 additions and 0 deletions
|
@ -133,6 +133,13 @@ func (s *Storage) search(workersCount int, so *genericSearchOptions, stopCh <-ch
|
||||||
bs := getBlockSearch()
|
bs := getBlockSearch()
|
||||||
for bsws := range workCh {
|
for bsws := range workCh {
|
||||||
for _, bsw := range bsws {
|
for _, bsw := range bsws {
|
||||||
|
select {
|
||||||
|
case <-stopCh:
|
||||||
|
// The search has been canceled. Just skip all the scheduled work in order to save CPU time.
|
||||||
|
continue
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
bs.search(bsw)
|
bs.search(bsw)
|
||||||
if bs.br.RowsCount() > 0 {
|
if bs.br.RowsCount() > 0 {
|
||||||
processBlockResult(workerID, &bs.br)
|
processBlockResult(workerID, &bs.br)
|
||||||
|
|
Loading…
Reference in a new issue