diff --git a/lib/logstorage/storage_search.go b/lib/logstorage/storage_search.go index a0be8ff0f..74e56c7fb 100644 --- a/lib/logstorage/storage_search.go +++ b/lib/logstorage/storage_search.go @@ -133,6 +133,13 @@ func (s *Storage) search(workersCount int, so *genericSearchOptions, stopCh <-ch bs := getBlockSearch() for bsws := range workCh { 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) if bs.br.RowsCount() > 0 { processBlockResult(workerID, &bs.br)