service/storage_service: Add and use xxhash feature
We add a cluster feature that informs whether the xxHash algorithm is supported, and allow nodes to switch to it. We use a cluster feature because older versions are not ready to receive a different digest algorithm than MD5 when answering a data request. If we ever should add a new hash algorithm, we would also need to add a new cluster feature for that algorithm. The alternative would be to add code so a coordinator could negotiate what digest algorithm to use with the set of replicas it is contacting. Fixes #2884 Signed-off-by: Duarte Nunes <duarte@scylladb.com>
This commit is contained in:
@@ -25,8 +25,8 @@ namespace query {
|
||||
|
||||
enum class digest_algorithm : uint8_t {
|
||||
none = 0, // digest not required
|
||||
MD5 = 1, // default algorithm
|
||||
xxHash = 2,
|
||||
MD5 = 1,
|
||||
xxHash = 2,// default algorithm
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ class query_result stub [[writable]] {
|
||||
|
||||
enum class digest_algorithm : uint8_t {
|
||||
none = 0, // digest not required
|
||||
MD5 = 1, // default algorithm
|
||||
MD5 = 1,
|
||||
xxHash = 2,// default algorithm
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2457,7 +2457,9 @@ public:
|
||||
};
|
||||
|
||||
query::digest_algorithm digest_algorithm() {
|
||||
return query::digest_algorithm::MD5;
|
||||
return service::get_local_storage_service().cluster_supports_xxhash_digest_algorithm()
|
||||
? query::digest_algorithm::xxHash
|
||||
: query::digest_algorithm::MD5;
|
||||
}
|
||||
|
||||
class abstract_read_executor : public enable_shared_from_this<abstract_read_executor> {
|
||||
|
||||
@@ -92,6 +92,7 @@ static const sstring CORRECT_COUNTER_ORDER_FEATURE = "CORRECT_COUNTER_ORDER";
|
||||
static const sstring SCHEMA_TABLES_V3 = "SCHEMA_TABLES_V3";
|
||||
static const sstring CORRECT_NON_COMPOUND_RANGE_TOMBSTONES = "CORRECT_NON_COMPOUND_RANGE_TOMBSTONES";
|
||||
static const sstring WRITE_FAILURE_REPLY_FEATURE = "WRITE_FAILURE_REPLY";
|
||||
static const sstring XXHASH_FEATURE = "XXHASH";
|
||||
|
||||
distributed<storage_service> _the_storage_service;
|
||||
|
||||
@@ -139,6 +140,7 @@ sstring storage_service::get_config_supported_features() {
|
||||
SCHEMA_TABLES_V3,
|
||||
CORRECT_NON_COMPOUND_RANGE_TOMBSTONES,
|
||||
WRITE_FAILURE_REPLY_FEATURE,
|
||||
XXHASH_FEATURE,
|
||||
};
|
||||
if (service::get_local_storage_service()._db.local().get_config().experimental()) {
|
||||
features.push_back(MATERIALIZED_VIEWS_FEATURE);
|
||||
@@ -351,6 +353,7 @@ void storage_service::register_features() {
|
||||
_schema_tables_v3 = gms::feature(SCHEMA_TABLES_V3);
|
||||
_correct_non_compound_range_tombstones = gms::feature(CORRECT_NON_COMPOUND_RANGE_TOMBSTONES);
|
||||
_write_failure_reply_feature = gms::feature(WRITE_FAILURE_REPLY_FEATURE);
|
||||
_xxhash_feature = gms::feature(XXHASH_FEATURE);
|
||||
|
||||
if (_db.local().get_config().experimental()) {
|
||||
_materialized_views_feature = gms::feature(MATERIALIZED_VIEWS_FEATURE);
|
||||
|
||||
@@ -275,6 +275,7 @@ private:
|
||||
gms::feature _schema_tables_v3;
|
||||
gms::feature _correct_non_compound_range_tombstones;
|
||||
gms::feature _write_failure_reply_feature;
|
||||
gms::feature _xxhash_feature;
|
||||
public:
|
||||
void enable_all_features() {
|
||||
_range_tombstones_feature.enable();
|
||||
@@ -287,6 +288,7 @@ public:
|
||||
_schema_tables_v3.enable();
|
||||
_correct_non_compound_range_tombstones.enable();
|
||||
_write_failure_reply_feature.enable();
|
||||
_xxhash_feature.enable();
|
||||
}
|
||||
|
||||
void finish_bootstrapping() {
|
||||
@@ -2259,6 +2261,10 @@ public:
|
||||
bool cluster_supports_write_failure_reply() const {
|
||||
return bool(_write_failure_reply_feature);
|
||||
}
|
||||
|
||||
bool cluster_supports_xxhash_digest_algorithm() const {
|
||||
return bool(_xxhash_feature);
|
||||
}
|
||||
};
|
||||
|
||||
inline future<> init_storage_service(distributed<database>& db, sharded<auth::service>& auth_service) {
|
||||
|
||||
Reference in New Issue
Block a user