Files
scylladb/locator/simple_strategy.hh
Sergey Zolotukhin 68a55facdf Add conditions checking for get_read_executor
During the investigation of scylladb/scylladb#20282, it was discovered that
implementations of speculating read executors have undefined behavior
when called with an incorrect number of read replicas. This PR
introduces two levels of condition checking:

- Condition checking in speculating read executors for the number of replicas.
- Checking the consistency of the Effective Replication Map in
  get_endpoints_for_reading(): the map is considered incorrect the number of
  read replica nodes is higher than replication factor. The check is
  applied only when built in non release mode.

Please note: This PR does not fix the issue found in scylladb/scylladb#20282;
it only adds condition checks to prevent undefined behavior in cases of
inconsistent inputs.

Refs scylladb/scylladb#20625

(cherry picked from commit c373edab2d)
2024-10-11 18:20:43 +00:00

36 lines
1.1 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "abstract_replication_strategy.hh"
#include <optional>
namespace locator {
class simple_strategy : public abstract_replication_strategy {
public:
simple_strategy(replication_strategy_params params);
virtual ~simple_strategy() {};
virtual size_t get_replication_factor(const token_metadata& tm) const override;
virtual void validate_options(const gms::feature_service&) const override;
virtual std::optional<std::unordered_set<sstring>> recognized_options(const topology&) const override;
virtual bool allow_remove_node_being_replaced_from_natural_endpoints() const override {
return true;
}
virtual future<host_id_set> calculate_natural_endpoints(const token& search_token, const token_metadata& tm) const override;
[[nodiscard]] sstring sanity_check_read_replicas(const effective_replication_map& erm, const inet_address_vector_replica_set& read_replicas) const override;
private:
size_t _replication_factor = 1;
};
}