Introduces shares-based workload prioritization for service levels, allowing fine-grained control over resource allocation between tenants. Key changes: - Add shares option to service level configuration: - Valid range: 1-1000 shares - Default value: 1000 shares - Enterprise-only feature gated by WORKLOAD_PRIORITIZATION feature flag - Extend CQL interface: - Add shares parameter to CREATE/ALTER SERVICE_LEVEL - Add shares column to system_distributed.service_levels - Add percentage calculation to LIST SERVICE_LEVELS - Add shares to DESCRIBE EFFECTIVE SERVICE_LEVEL output - Add validation: - Enforce shares range (1-1000) - Validate enterprise feature flag - Handle unset/delete markers properly - Update service level statements: - Add shares validation to CREATE/ALTER operations - Preserve shares through default value replacement - Add proper decomposition for shares values in result sets This change enables operators to control relative resource allocation between tenants using proportional share scheduling, while maintaining backward compatibility with existing service level configurations.
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "cql3/cql_statement.hh"
|
|
#include "cql3/query_processor.hh"
|
|
#include "raw/parsed_statement.hh"
|
|
#include "service/qos/qos_common.hh"
|
|
#include "service/query_state.hh"
|
|
|
|
namespace cql3 {
|
|
|
|
namespace statements {
|
|
|
|
///
|
|
/// A logical argument error for a service_level statement operation.
|
|
///
|
|
class service_level_argument_exception : public std::invalid_argument {
|
|
public:
|
|
using std::invalid_argument::invalid_argument;
|
|
};
|
|
|
|
///
|
|
/// An exception to indicate that the service level given as parameter doesn't exist.
|
|
///
|
|
class nonexitent_service_level_exception : public service_level_argument_exception {
|
|
public:
|
|
nonexitent_service_level_exception(sstring service_level_name)
|
|
: service_level_argument_exception(format("Service Level {} doesn't exists.", service_level_name)) {
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
class service_level_statement : public raw::parsed_statement, public cql_statement_no_metadata {
|
|
public:
|
|
service_level_statement() : cql_statement_no_metadata(&timeout_config::other_timeout) {}
|
|
|
|
virtual bool needs_guard(query_processor& qp, service::query_state& state) const override;
|
|
|
|
uint32_t get_bound_terms() const override;
|
|
|
|
bool depends_on(std::string_view ks_name, std::optional<std::string_view> cf_name) const override;
|
|
|
|
future<> check_access(query_processor& qp, const service::client_state& state) const override;
|
|
protected:
|
|
virtual audit::statement_category category() const override;
|
|
|
|
virtual audit::audit_info_ptr audit_info() const override;
|
|
|
|
void validate_shares_option(const query_processor& qp, const qos::service_level_options& slo) const;
|
|
};
|
|
|
|
}
|
|
}
|