From 86e8be2dcd656d9cfa5974c55f8b77dbc09c52bf Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 17 Aug 2023 17:08:46 +0800 Subject: [PATCH] replica:database: log if endpoint not found if the endpoint specified when creating a KEYSPACE is not found, when flushing a memtable, we would throw an `std::out_of_range` exception when looking up the client in `storage_manager::_s3_endpoints` by the name of endpoint. and scylla would crash because of it. so far, we don't have a good way to error out early. since the storage option for keyspace is still experimental, we can live with this, but would be better if we can spot this error in logging messages when testing this feature. also, in this change, `std::invalid_argument` is thrown instead of `std::out_of_range`. it's more appropriate in this circumstance. Refs #15074 Signed-off-by: Kefu Chai Closes #15075 --- sstables/sstables_manager.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sstables/sstables_manager.cc b/sstables/sstables_manager.cc index 8a15d9204d..2c5b5a3c2f 100644 --- a/sstables/sstables_manager.cc +++ b/sstables/sstables_manager.cc @@ -75,7 +75,12 @@ void storage_manager::update_config(const db::config& cfg) { } shared_ptr storage_manager::get_endpoint_client(sstring endpoint) { - auto& ep = _s3_endpoints.at(endpoint); + auto found = _s3_endpoints.find(endpoint); + if (found == _s3_endpoints.end()) { + smlogger.error("unable to find {} in configured object-storage endpoints", endpoint); + throw std::invalid_argument(format("endpoint {} not found", endpoint)); + } + auto& ep = found->second; if (ep.client == nullptr) { ep.client = s3::client::make(endpoint, ep.cfg, [ &ct = container() ] (std::string ep) { return ct.local().get_endpoint_client(ep);