Today, the "system.clients" virtual table lists active connections (and
their various properties, like client address, logged in username and
client version) only for CQL requests. In this patch we make Alternator
active clients also be listed on this virtual table.
Unlike CQL where logged in username applies to a complete connection,
in the Alternator API, different requests, theoretically signed by
different users, can arrive over the same HTTP connection. So instead of
listing the currently open *connections*, we list the currently active
*requests*.
This means that when scanning system.clients, you will only see requests
which are being handled right now - and not inactive HTTP connections.
I think this good enough (besides being the correct thing to do) - one
of the goals of this system.clients is to be able to see what kind of
drivers are being used by the user (the "driver_name" field in the
system.clients) - on a busy server there will always be some (even many)
requests being handled, so we'll always have plenty of requests to see
in system.clients.
By the way, note that for Alternator requests, what we use for the
"driver_name" is the request's User-Agent header. AWS SDKs typically
write the driver's name, its version, and often a lot of other
information in that header. For example, Boto3 sends a User-Agent
looking like:
Boto3/1.38.46 md/Botocore#1.38.46 md/awscrt#0.24.2
ua/2.1 os/linux#6.15.4-100.fc41.x86_64 md/arch#x86_64
lang/python#3.13.5 md/pyimpl#CPython m/N,P,b,D,Z
cfg/retry-mode#legacy Botocore/1.38.46 Resource
A functional test for the new feature - adding Alternator requests to
the system.clients table - will be in the next patch.
Fixes #24993
Signed-off-by: Nadav Har'El <nyh@scylladb.com>
100 lines
2.6 KiB
C++
100 lines
2.6 KiB
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/sharded.hh>
|
|
#include <seastar/core/smp.hh>
|
|
|
|
#include "protocol_server.hh"
|
|
|
|
namespace service {
|
|
class storage_proxy;
|
|
class migration_manager;
|
|
class memory_limiter;
|
|
}
|
|
|
|
namespace db {
|
|
class system_distributed_keyspace;
|
|
class config;
|
|
}
|
|
|
|
namespace cdc {
|
|
class generation_service;
|
|
}
|
|
|
|
namespace gms {
|
|
|
|
class gossiper;
|
|
|
|
}
|
|
|
|
namespace auth {
|
|
class service;
|
|
}
|
|
|
|
namespace qos {
|
|
class service_level_controller;
|
|
}
|
|
|
|
namespace alternator {
|
|
|
|
// This is the official DynamoDB API version.
|
|
// It represents the last major reorganization of that API, and all the features
|
|
// that were added since did NOT increment this version string.
|
|
constexpr const char* version = "2012-08-10";
|
|
|
|
using namespace seastar;
|
|
|
|
class executor;
|
|
class server;
|
|
|
|
class controller : public protocol_server {
|
|
sharded<gms::gossiper>& _gossiper;
|
|
sharded<service::storage_proxy>& _proxy;
|
|
sharded<service::migration_manager>& _mm;
|
|
sharded<db::system_distributed_keyspace>& _sys_dist_ks;
|
|
sharded<cdc::generation_service>& _cdc_gen_svc;
|
|
sharded<service::memory_limiter>& _memory_limiter;
|
|
sharded<auth::service>& _auth_service;
|
|
sharded<qos::service_level_controller>& _sl_controller;
|
|
const db::config& _config;
|
|
|
|
std::vector<socket_address> _listen_addresses;
|
|
sharded<executor> _executor;
|
|
sharded<server> _server;
|
|
std::optional<smp_service_group> _ssg;
|
|
|
|
public:
|
|
controller(
|
|
sharded<gms::gossiper>& gossiper,
|
|
sharded<service::storage_proxy>& proxy,
|
|
sharded<service::migration_manager>& mm,
|
|
sharded<db::system_distributed_keyspace>& sys_dist_ks,
|
|
sharded<cdc::generation_service>& cdc_gen_svc,
|
|
sharded<service::memory_limiter>& memory_limiter,
|
|
sharded<auth::service>& auth_service,
|
|
sharded<qos::service_level_controller>& sl_controller,
|
|
const db::config& config,
|
|
seastar::scheduling_group sg);
|
|
|
|
virtual sstring name() const override;
|
|
virtual sstring protocol() const override;
|
|
virtual sstring protocol_version() const override;
|
|
virtual std::vector<socket_address> listen_addresses() const override;
|
|
virtual future<> start_server() override;
|
|
virtual future<> stop_server() override;
|
|
virtual future<> request_stop_server() override;
|
|
// This virtual function is called (on each shard separately) when the
|
|
// virtual table "system.clients" is read. It is expected to generate a
|
|
// list of clients connected to this server (on this shard).
|
|
virtual future<utils::chunked_vector<client_data>> get_client_data() override;
|
|
};
|
|
|
|
}
|