From c274fdf2ec6e32f59f4efdadbd3632ff5c26cb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Mon, 4 Jun 2018 14:10:17 +0300 Subject: [PATCH] querier: find_querier(): return end() when no querier matches the range When none of the queriers found for the lookup key match the lookup range `_entries.end()` should be returned as the search failed. Instead the iterator returned from the failed `std::find_if()` is returned which, if the find failed, will be the end iterator returned by the previous call to `_entries.equal_range()`. This is incorrect because as long as `equal_range()`'s end iterator is not also `_entries.end()` the search will always return an iterator to a querier regardless of whether any of them actually matches the read range. Fix by returning `_entries.end()` when it is detected that no queriers match the range. Fixes: #3530 (cherry picked from commit 2609a17a23e8ea5290a50f1f0192c7c23e14d4f3) --- querier.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/querier.cc b/querier.cc index 53e18f3d8f..34ba9a7d56 100644 --- a/querier.cc +++ b/querier.cc @@ -175,6 +175,7 @@ querier_cache::entries::iterator querier_cache::find_querier(utils::UUID key, co if (it == queriers.second) { tracing::trace(trace_state, "Found cached querier(s) for key {} but none matches the query range {}", key, range); + return _entries.end(); } tracing::trace(trace_state, "Found cached querier for key {} and range {}", key, range); return it->pos();