diff --git a/redis/options.hh b/redis/options.hh index 35ee33b123..05500450ed 100644 --- a/redis/options.hh +++ b/redis/options.hh @@ -60,7 +60,7 @@ public: ,_read_consistency(rcl) ,_write_consistency(wcl) ,_timeout_config(tc) - ,_client_state(service::client_state::external_tag{}, auth, addr) + ,_client_state(service::client_state::external_tag{}, auth, tc, addr) ,_total_redis_db_count(total_redis_db_count) { } @@ -75,7 +75,7 @@ public: ,_read_consistency(rcl) ,_write_consistency(wcl) ,_timeout_config(tc) - ,_client_state(service::client_state::external_tag{}, auth, addr) + ,_client_state(service::client_state::external_tag{}, auth, tc, addr) ,_total_redis_db_count(total_redis_db_count) { } diff --git a/service/client_state.hh b/service/client_state.hh index 8a1c22c560..5537e0bd1f 100644 --- a/service/client_state.hh +++ b/service/client_state.hh @@ -44,6 +44,7 @@ #include "auth/service.hh" #include "exceptions/exceptions.hh" #include "unimplemented.hh" +#include "timeout_config.hh" #include "timestamp.hh" #include "db_clock.hh" #include "database_fwd.hh" @@ -88,10 +89,17 @@ public: }; private: client_state(const client_state* cs, seastar::sharded* auth_service) - : _keyspace(cs->_keyspace), _user(cs->_user), _auth_state(cs->_auth_state), - _is_internal(cs->_is_internal), _is_thrift(cs->_is_thrift), _remote_address(cs->_remote_address), - _auth_service(auth_service ? &auth_service->local() : nullptr), - _enabled_protocol_extensions(cs->_enabled_protocol_extensions) {} + : _keyspace(cs->_keyspace) + , _user(cs->_user) + , _auth_state(cs->_auth_state) + , _is_internal(cs->_is_internal) + , _is_thrift(cs->_is_thrift) + , _remote_address(cs->_remote_address) + , _auth_service(auth_service ? &auth_service->local() : nullptr) + , _default_timeout_config(cs->_default_timeout_config) + , _timeout_config(cs->_timeout_config) + , _enabled_protocol_extensions(cs->_enabled_protocol_extensions) + {} friend client_state_for_another_shard; private: sstring _keyspace; @@ -136,6 +144,10 @@ private: // Only populated for external client state. auth::service* _auth_service{nullptr}; + // For restoring default values in the timeout config + timeout_config _default_timeout_config; + timeout_config _timeout_config; + public: struct internal_tag {}; struct external_tag {}; @@ -162,11 +174,13 @@ public: _driver_version = std::move(driver_version); } - client_state(external_tag, auth::service& auth_service, const socket_address& remote_address = socket_address(), bool thrift = false) + client_state(external_tag, auth::service& auth_service, timeout_config timeout_config, const socket_address& remote_address = socket_address(), bool thrift = false) : _is_internal(false) , _is_thrift(thrift) , _remote_address(remote_address) - , _auth_service(&auth_service) { + , _auth_service(&auth_service) + , _default_timeout_config(timeout_config) + , _timeout_config(timeout_config) { if (!auth_service.underlying_authenticator().require_authentication()) { _user = auth::authenticated_user(); } @@ -180,10 +194,16 @@ public: return _remote_address.port(); } + const timeout_config& get_timeout_config() const { + return _timeout_config; + } + client_state(internal_tag) : _keyspace("system") , _is_internal(true) , _is_thrift(false) + , _default_timeout_config(infinite_timeout_config) + , _timeout_config(infinite_timeout_config) {} client_state(const client_state&) = delete; diff --git a/test/lib/cql_test_env.cc b/test/lib/cql_test_env.cc index 547951ef10..a25d1e288c 100644 --- a/test/lib/cql_test_env.cc +++ b/test/lib/cql_test_env.cc @@ -126,7 +126,7 @@ private: service::client_state client_state; core_local_state(auth::service& auth_service) - : client_state(service::client_state::external_tag{}, auth_service) + : client_state(service::client_state::external_tag{}, auth_service, infinite_timeout_config) { client_state.set_login(auth::authenticated_user(testing_superuser)); } diff --git a/thrift/handler.cc b/thrift/handler.cc index b98cee6083..9a79d61978 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -201,9 +201,9 @@ enum class query_order { no, yes }; class thrift_handler : public CassandraCobSvIf { distributed& _db; distributed& _query_processor; + ::timeout_config _timeout_config; service::client_state _client_state; service::query_state _query_state; - ::timeout_config _timeout_config; private: template void @@ -220,9 +220,9 @@ public: explicit thrift_handler(distributed& db, distributed& qp, auth::service& auth_service, ::timeout_config timeout_config) : _db(db) , _query_processor(qp) - , _client_state(service::client_state::external_tag{}, auth_service, socket_address(), true) - , _query_state(_client_state, /*FIXME: pass real permit*/empty_service_permit()) , _timeout_config(timeout_config) + , _client_state(service::client_state::external_tag{}, auth_service, _timeout_config, socket_address(), true) + , _query_state(_client_state, /*FIXME: pass real permit*/empty_service_permit()) { } const sstring& current_keyspace() const { diff --git a/transport/server.cc b/transport/server.cc index 655e76a74d..72771610b0 100644 --- a/transport/server.cc +++ b/transport/server.cc @@ -608,7 +608,7 @@ cql_server::connection::connection(cql_server& server, socket_address server_add , _fd(std::move(fd)) , _read_buf(_fd.input()) , _write_buf(_fd.output()) - , _client_state(service::client_state::external_tag{}, server._auth_service, addr) + , _client_state(service::client_state::external_tag{}, server._auth_service, server.timeout_config(), addr) { ++_server._total_connections; ++_server._current_connections;