locator: erm: Make get_endpoints_for_reading() always return read replicas
Just a simplification. Drop the test case from token_metadata which creates pending endpoints without normal tokens. It fails after this change with exception: "sorted_tokens is empty in first_token_index!" thrown from token_metadata::first_token_index(), which is used when calculating normal endpoints. This test case is not valid, first node inserts its tokens as normal without going through bootstrap procedure.
This commit is contained in:
@@ -112,10 +112,10 @@ inet_address_vector_topology_change vnode_effective_replication_map::get_pending
|
||||
return endpoints;
|
||||
}
|
||||
|
||||
std::optional<inet_address_vector_replica_set> vnode_effective_replication_map::get_endpoints_for_reading(const token& token) const {
|
||||
inet_address_vector_replica_set vnode_effective_replication_map::get_endpoints_for_reading(const token& token) const {
|
||||
const auto* endpoints = find_token(_read_endpoints, token);
|
||||
if (endpoints == nullptr) {
|
||||
return {};
|
||||
return get_natural_endpoints_without_node_being_replaced(token);
|
||||
}
|
||||
return inet_address_vector_replica_set(endpoints->begin(), endpoints->end());
|
||||
}
|
||||
|
||||
@@ -201,9 +201,7 @@ public:
|
||||
virtual inet_address_vector_topology_change get_pending_endpoints(const token& search_token) const = 0;
|
||||
|
||||
/// Returns a list of nodes to which a read request should be directed.
|
||||
/// Returns not null only during topology changes, if request_read_new was called and
|
||||
/// new set of replicas differs from the old one.
|
||||
virtual std::optional<inet_address_vector_replica_set> get_endpoints_for_reading(const token& search_token) const = 0;
|
||||
virtual inet_address_vector_replica_set get_endpoints_for_reading(const token& search_token) const = 0;
|
||||
|
||||
/// Returns true if there are any pending ranges for this endpoint.
|
||||
/// This operation is expensive, for vnode_erm it iterates
|
||||
@@ -279,7 +277,7 @@ public: // effective_replication_map
|
||||
inet_address_vector_replica_set get_natural_endpoints(const token& search_token) const override;
|
||||
inet_address_vector_replica_set get_natural_endpoints_without_node_being_replaced(const token& search_token) const override;
|
||||
inet_address_vector_topology_change get_pending_endpoints(const token& search_token) const override;
|
||||
std::optional<inet_address_vector_replica_set> get_endpoints_for_reading(const token& search_token) const override;
|
||||
inet_address_vector_replica_set get_endpoints_for_reading(const token& search_token) const override;
|
||||
bool has_pending_ranges(inet_address endpoint) const override;
|
||||
std::unique_ptr<token_range_splitter> make_splitter() const override;
|
||||
const dht::sharder& get_sharder(const schema& s) const override;
|
||||
|
||||
@@ -260,8 +260,8 @@ public:
|
||||
return {get_endpoint_for_host_id(info->pending_replica.host)};
|
||||
}
|
||||
|
||||
virtual std::optional<inet_address_vector_replica_set> get_endpoints_for_reading(const token& search_token) const override {
|
||||
return std::nullopt;
|
||||
virtual inet_address_vector_replica_set get_endpoints_for_reading(const token& search_token) const override {
|
||||
return get_natural_endpoints_without_node_being_replaced(search_token);
|
||||
}
|
||||
|
||||
virtual bool has_pending_ranges(inet_address endpoint) const override {
|
||||
|
||||
Reference in New Issue
Block a user