mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
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)
36 lines
1.1 KiB
C++
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;
|
|
};
|
|
|
|
}
|