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 2609a17a23)
This commit is contained in:
Botond Dénes
2018-06-04 14:10:17 +03:00
committed by Avi Kivity
parent 5b88d6b4d6
commit c274fdf2ec

View File

@@ -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();