storage_service: get_all_ranges: reserve enough space in ranges

Commit bc5f6cf45d
added a reserve call to the `ranges` vector before
inserting all the returned token ranges into it.
However, that reservation is too small as we need
to express size+1 ranges for size tokens with
<unbound, token[0]> and <token[size-1], unbound>
ranges at the front and back, respectively.

Fixes #14849

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>

Closes #14938
This commit is contained in:
Benny Halevy
2023-08-03 07:53:47 +03:00
committed by Avi Kivity
parent 946c6487ee
commit 46c9e3032d

View File

@@ -6078,7 +6078,7 @@ storage_service::get_all_ranges(const std::vector<token>& sorted_tokens) const {
co_return dht::token_range_vector();
int size = sorted_tokens.size();
dht::token_range_vector ranges;
ranges.reserve(size);
ranges.reserve(size + 1);
ranges.push_back(dht::token_range::make_ending_with(range_bound<token>(sorted_tokens[0], true)));
co_await coroutine::maybe_yield();
for (int i = 1; i < size; ++i) {