From d542cdddf6387a365e5c47bf2baeae1ecb6d5ca3 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 5 May 2017 05:26:20 +0300 Subject: [PATCH 1/3] thrift: change generated code namespace org::apache::cassandra (the generated namespace name) gets confused with apache::cassandra (the thrift runtime library namespace), either due to changes in gcc 7 or in thrift 0.10. Either way, the problem is fixed by changing the generated namespace to plain cassandra. --- db/system_keyspace.cc | 2 +- interface/cassandra.thrift | 2 +- thrift/handler.cc | 4 ++-- thrift/handler.hh | 2 +- thrift/server.cc | 2 +- thrift/server.hh | 6 +++--- thrift/thrift_validation.hh | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 9a13dac893..cc263c33d3 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -446,7 +446,7 @@ static future<> setup_version() { sstring(db::system_keyspace::LOCAL), version::release(), cql3::query_processor::CQL_VERSION, - org::apache::cassandra::thrift_version, + ::cassandra::thrift_version, to_sstring(cql_serialization_format::latest_version), snitch->get_datacenter(utils::fb_utilities::get_broadcast_address()), snitch->get_rack(utils::fb_utilities::get_broadcast_address()), diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index 9a7d324b3e..2b3c70048a 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -34,7 +34,7 @@ # namespace java org.apache.cassandra.thrift -namespace cpp org.apache.cassandra +namespace cpp cassandra namespace csharp Apache.Cassandra namespace py cassandra namespace php cassandra diff --git a/thrift/handler.cc b/thrift/handler.cc index 4d0a8df600..4f77864c7f 100644 --- a/thrift/handler.cc +++ b/thrift/handler.cc @@ -58,7 +58,7 @@ using namespace ::apache::thrift::protocol; using namespace ::apache::thrift::transport; using namespace ::apache::thrift::async; -using namespace ::org::apache::cassandra; +using namespace ::cassandra; using namespace thrift; @@ -687,7 +687,7 @@ public: } void describe_version(tcxx::function cob) { - cob(org::apache::cassandra::thrift_version); + cob(::cassandra::thrift_version); } void do_describe_ring(tcxx::function const& _return)> cob, tcxx::function exn_cob, const std::string& keyspace, bool local) { diff --git a/thrift/handler.hh b/thrift/handler.hh index 3a9a1473bc..2267980881 100644 --- a/thrift/handler.hh +++ b/thrift/handler.hh @@ -28,6 +28,6 @@ #include "cql3/query_processor.hh" #include -std::unique_ptr create_handler_factory(distributed& db, distributed& qp); +std::unique_ptr<::cassandra::CassandraCobSvIfFactory> create_handler_factory(distributed& db, distributed& qp); #endif /* APPS_SEASTAR_THRIFT_HANDLER_HH_ */ diff --git a/thrift/server.cc b/thrift/server.cc index 4ae125181a..723ed99363 100644 --- a/thrift/server.cc +++ b/thrift/server.cc @@ -48,7 +48,7 @@ using namespace apache::thrift; using namespace apache::thrift::transport; using namespace apache::thrift::protocol; using namespace apache::thrift::async; -using namespace org::apache::cassandra; +using namespace ::cassandra; class thrift_stats { seastar::metrics::metric_groups _metrics; diff --git a/thrift/server.hh b/thrift/server.hh index 9a35841c24..512aa9b643 100644 --- a/thrift/server.hh +++ b/thrift/server.hh @@ -32,13 +32,13 @@ class thrift_server; class thrift_stats; class database; -namespace org { namespace apache { namespace cassandra { +namespace cassandra { static const sstring thrift_version = "20.1.0"; class CassandraCobSvIfFactory; -}}} +} namespace apache { namespace thrift { namespace protocol { @@ -56,7 +56,7 @@ class TAsyncProcessorFactory; class thrift_server { std::vector _listeners; std::unique_ptr _stats; - boost::shared_ptr _handler_factory; + boost::shared_ptr<::cassandra::CassandraCobSvIfFactory> _handler_factory; std::unique_ptr _protocol_factory; boost::shared_ptr _processor_factory; uint64_t _total_connections = 0; diff --git a/thrift/thrift_validation.hh b/thrift/thrift_validation.hh index ccef9a9424..0c1d0d8d08 100644 --- a/thrift/thrift_validation.hh +++ b/thrift/thrift_validation.hh @@ -45,7 +45,7 @@ #include "bytes.hh" #include "Cassandra.h" -using namespace ::org::apache::cassandra; +using namespace ::cassandra; #if 0 import java.nio.ByteBuffer; From 5278e1a14dc357197a16039c0606fcecab52bcff Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 5 May 2017 07:02:53 +0300 Subject: [PATCH 2/3] commitlog: handle noexcept conflict between unlink and function object ::unlink is declared as noexcept, but the function object it is passed into is not. gcc 7 warns, so wrap ::unlink in a lambda to make it happy. --- db/commitlog/commitlog.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 0a8400eed0..31803174b4 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -436,7 +436,8 @@ public: _segment_manager->totals.total_size_on_disk -= size_on_disk(); _segment_manager->totals.total_size -= (size_on_disk() + _buffer.size()); try { - commit_io_check(::unlink, _file_name.c_str()); + commit_io_check([] (const char* fname) { ::unlink(fname); }, + _file_name.c_str()); } catch (...) { logger.error("Could not delete segment {}: {}", *this, std::current_exception()); } From a592573491832fbc17db68b552908d739438496b Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 5 May 2017 07:01:38 +0300 Subject: [PATCH 3/3] Remove exception specifications C++17 removed exception specifications from the language, and gcc 7 warns about them even in C++14 mode. Remove them from the code base. --- auth/auth.cc | 5 ++--- auth/auth.hh | 4 ++-- auth/authenticator.cc | 10 +++++----- auth/authenticator.hh | 14 +++++++------- auth/data_resource.cc | 6 ++---- auth/data_resource.hh | 4 ++-- auth/password_authenticator.cc | 21 ++++++--------------- auth/password_authenticator.hh | 8 ++++---- query-result-set.hh | 14 ++++++++------ service/client_state.cc | 2 +- service/client_state.hh | 2 +- sstables/hyperloglog.hh | 6 +++--- 12 files changed, 43 insertions(+), 53 deletions(-) diff --git a/auth/auth.cc b/auth/auth.cc index c1f9a2326f..16b5af00ad 100644 --- a/auth/auth.cc +++ b/auth/auth.cc @@ -331,14 +331,13 @@ future auth::auth::is_super_user(const sstring& username) { }); } -future<> auth::auth::insert_user(const sstring& username, bool is_super) - throw (exceptions::request_execution_exception) { +future<> auth::auth::insert_user(const sstring& username, bool is_super) { return cql3::get_local_query_processor().process(sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?)", AUTH_KS, USERS_CF, USER_NAME, SUPER), consistency_for_user(username), { username, is_super }).discard_result(); } -future<> auth::auth::delete_user(const sstring& username) throw(exceptions::request_execution_exception) { +future<> auth::auth::delete_user(const sstring& username) { return cql3::get_local_query_processor().process(sprint("DELETE FROM %s.%s WHERE %s = ?", AUTH_KS, USERS_CF, USER_NAME), consistency_for_user(username), { username }).discard_result(); diff --git a/auth/auth.hh b/auth/auth.hh index d1a284c93e..4ecca54586 100644 --- a/auth/auth.hh +++ b/auth/auth.hh @@ -91,7 +91,7 @@ public: * @param isSuper User's new status. * @throws RequestExecutionException */ - static future<> insert_user(const sstring& username, bool is_super) throw(exceptions::request_execution_exception); + static future<> insert_user(const sstring& username, bool is_super); /** * Deletes the user from AUTH_KS.USERS_CF. @@ -99,7 +99,7 @@ public: * @param username Username to delete. * @throws RequestExecutionException */ - static future<> delete_user(const sstring& username) throw(exceptions::request_execution_exception); + static future<> delete_user(const sstring& username); /** * Sets up Authenticator and Authorizer. diff --git a/auth/authenticator.cc b/auth/authenticator.cc index ee7c3e5953..83131fa9d9 100644 --- a/auth/authenticator.cc +++ b/auth/authenticator.cc @@ -72,7 +72,7 @@ sstring auth::authenticator::option_to_string(option opt) { static std::unique_ptr global_authenticator; future<> -auth::authenticator::setup(const sstring& type) throw (exceptions::configuration_exception) { +auth::authenticator::setup(const sstring& type) { if (auth::auth::is_class_type(type, ALLOW_ALL_AUTHENTICATOR_NAME)) { class allow_all_authenticator : public authenticator { public: @@ -88,16 +88,16 @@ auth::authenticator::setup(const sstring& type) throw (exceptions::configuration option_set alterable_options() const override { return option_set(); } - future<::shared_ptr> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) override { + future<::shared_ptr> authenticate(const credentials_map& credentials) const override { return make_ready_future<::shared_ptr>(::make_shared()); } - future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override { + future<> create(sstring username, const option_map& options) override { return make_ready_future(); } - future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override { + future<> alter(sstring username, const option_map& options) override { return make_ready_future(); } - future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override { + future<> drop(sstring username) override { return make_ready_future(); } const resource_ids& protected_resources() const override { diff --git a/auth/authenticator.hh b/auth/authenticator.hh index 2a0321c9f7..2459338448 100644 --- a/auth/authenticator.hh +++ b/auth/authenticator.hh @@ -92,7 +92,7 @@ public: * For example, use this method to create any required keyspaces/column families. * Note: Only call from main thread. */ - static future<> setup(const sstring& type) throw(exceptions::configuration_exception); + static future<> setup(const sstring& type); /** * Returns the system authenticator. Must have called setup before calling this. @@ -129,7 +129,7 @@ public: * * @throws authentication_exception if credentials don't match any known user. */ - virtual future<::shared_ptr> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) = 0; + virtual future<::shared_ptr> authenticate(const credentials_map& credentials) const = 0; /** * Called during execution of CREATE USER query (also may be called on startup, see seedSuperuserOptions method). @@ -141,7 +141,7 @@ public: * @throws exceptions::request_validation_exception * @throws exceptions::request_execution_exception */ - virtual future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0; + virtual future<> create(sstring username, const option_map& options) = 0; /** * Called during execution of ALTER USER query. @@ -154,7 +154,7 @@ public: * @throws exceptions::request_validation_exception * @throws exceptions::request_execution_exception */ - virtual future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0; + virtual future<> alter(sstring username, const option_map& options) = 0; /** @@ -164,7 +164,7 @@ public: * @throws exceptions::request_validation_exception * @throws exceptions::request_execution_exception */ - virtual future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) = 0; + virtual future<> drop(sstring username) = 0; /** * Set of resources that should be made inaccessible to users and only accessible internally. @@ -177,9 +177,9 @@ public: class sasl_challenge { public: virtual ~sasl_challenge() {} - virtual bytes evaluate_response(bytes_view client_response) throw(exceptions::authentication_exception) = 0; + virtual bytes evaluate_response(bytes_view client_response) = 0; virtual bool is_complete() const = 0; - virtual future<::shared_ptr> get_authenticated_user() const throw(exceptions::authentication_exception) = 0; + virtual future<::shared_ptr> get_authenticated_user() const = 0; }; /** diff --git a/auth/data_resource.cc b/auth/data_resource.cc index f81d73dc1b..7af829d7c9 100644 --- a/auth/data_resource.cc +++ b/auth/data_resource.cc @@ -115,16 +115,14 @@ auth::data_resource auth::data_resource::get_parent() const { } } -const sstring& auth::data_resource::keyspace() const - throw (std::invalid_argument) { +const sstring& auth::data_resource::keyspace() const { if (is_root_level()) { throw std::invalid_argument("ROOT data resource has no keyspace"); } return _ks; } -const sstring& auth::data_resource::column_family() const - throw (std::invalid_argument) { +const sstring& auth::data_resource::column_family() const { if (!is_column_family_level()) { throw std::invalid_argument(sprint("%s data resource has no column family", name())); } diff --git a/auth/data_resource.hh b/auth/data_resource.hh index f5aed16259..2b1deb446d 100644 --- a/auth/data_resource.hh +++ b/auth/data_resource.hh @@ -117,13 +117,13 @@ public: * @return keyspace of the resource. * @throws std::invalid_argument if it's the root-level resource. */ - const sstring& keyspace() const throw(std::invalid_argument); + const sstring& keyspace() const; /** * @return column family of the resource. * @throws std::invalid_argument if it's not a cf-level resource. */ - const sstring& column_family() const throw(std::invalid_argument); + const sstring& column_family() const; /** * @return Whether or not the resource has a parent in the hierarchy. diff --git a/auth/password_authenticator.cc b/auth/password_authenticator.cc index 2812f6744e..118baee8ea 100644 --- a/auth/password_authenticator.cc +++ b/auth/password_authenticator.cc @@ -201,8 +201,7 @@ auth::authenticator::option_set auth::password_authenticator::alterable_options( } future<::shared_ptr > auth::password_authenticator::authenticate( - const credentials_map& credentials) const - throw (exceptions::authentication_exception) { + const credentials_map& credentials) const { if (!credentials.count(USERNAME_KEY)) { throw exceptions::authentication_exception(sprint("Required key '%s' is missing", USERNAME_KEY)); } @@ -241,9 +240,7 @@ future<::shared_ptr > auth::password_authenticator::au } future<> auth::password_authenticator::create(sstring username, - const option_map& options) - throw (exceptions::request_validation_exception, - exceptions::request_execution_exception) { + const option_map& options) { try { auto password = boost::any_cast(options.at(option::PASSWORD)); auto query = sprint("INSERT INTO %s.%s (%s, %s) VALUES (?, ?)", @@ -256,9 +253,7 @@ future<> auth::password_authenticator::create(sstring username, } future<> auth::password_authenticator::alter(sstring username, - const option_map& options) - throw (exceptions::request_validation_exception, - exceptions::request_execution_exception) { + const option_map& options) { try { auto password = boost::any_cast(options.at(option::PASSWORD)); auto query = sprint("UPDATE %s.%s SET %s = ? WHERE %s = ?", @@ -270,9 +265,7 @@ future<> auth::password_authenticator::alter(sstring username, } } -future<> auth::password_authenticator::drop(sstring username) - throw (exceptions::request_validation_exception, - exceptions::request_execution_exception) { +future<> auth::password_authenticator::drop(sstring username) { try { auto query = sprint("DELETE FROM %s.%s WHERE %s = ?", auth::AUTH_KS, CREDENTIALS_CF, USER_NAME); @@ -308,8 +301,7 @@ const auth::resource_ids& auth::password_authenticator::protected_resources() co * would expect * @throws javax.security.sasl.SaslException */ - bytes evaluate_response(bytes_view client_response) - throw (exceptions::authentication_exception) override { + bytes evaluate_response(bytes_view client_response) override { logger.debug("Decoding credentials from client token"); sstring username, password; @@ -347,8 +339,7 @@ const auth::resource_ids& auth::password_authenticator::protected_resources() co bool is_complete() const override { return _complete; } - future<::shared_ptr> get_authenticated_user() const - throw (exceptions::authentication_exception) override { + future<::shared_ptr> get_authenticated_user() const override { return _authenticator.authenticate(_credentials); } private: diff --git a/auth/password_authenticator.hh b/auth/password_authenticator.hh index f9759563c1..08c1767980 100644 --- a/auth/password_authenticator.hh +++ b/auth/password_authenticator.hh @@ -58,10 +58,10 @@ public: bool require_authentication() const override; option_set supported_options() const override; option_set alterable_options() const override; - future<::shared_ptr> authenticate(const credentials_map& credentials) const throw(exceptions::authentication_exception) override; - future<> create(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override; - future<> alter(sstring username, const option_map& options) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override; - future<> drop(sstring username) throw(exceptions::request_validation_exception, exceptions::request_execution_exception) override; + future<::shared_ptr> authenticate(const credentials_map& credentials) const override; + future<> create(sstring username, const option_map& options) override; + future<> alter(sstring username, const option_map& options) override; + future<> drop(sstring username) override; const resource_ids& protected_resources() const override; ::shared_ptr new_sasl_challenge() const override; diff --git a/query-result-set.hh b/query-result-set.hh index 482bf7c9b6..d2ba4bb0ec 100644 --- a/query-result-set.hh +++ b/query-result-set.hh @@ -56,27 +56,28 @@ public: bool has(const sstring& column_name) const { return _cells.count(column_name) > 0; } - // Look up a deserialized row cell value by column name. + // Look up a deserialized row cell value by column name; throws no_such_column on error const data_value& - get_data_value(const sstring& column_name) const throw (no_such_column) { + get_data_value(const sstring& column_name) const { auto it = _cells.find(column_name); if (it == _cells.end()) { throw no_such_column(column_name); } return it->second; } - // Look up a deserialized row cell value by column name. + // Look up a deserialized row cell value by column name; throws no_such_column on error. template std::experimental::optional - get(const sstring& column_name) const throw (no_such_column) { + get(const sstring& column_name) const { auto&& value = get_data_value(column_name); if (value.is_null()) { return std::experimental::nullopt; } return std::experimental::optional{value_cast(value)}; } + // throws no_such_column or null_column_value on error template - T get_nonnull(const sstring& column_name) const throw (no_such_column, null_column_value) { + T get_nonnull(const sstring& column_name) const { auto v = get(column_name); if (v) { return *v; @@ -112,7 +113,8 @@ public: bool empty() const { return _rows.empty(); } - const result_set_row& row(size_t idx) const throw (std::out_of_range) { + // throws std::out_of_range on error + const result_set_row& row(size_t idx) const { if (idx >= _rows.size()) { throw std::out_of_range("no such row in result set: " + std::to_string(idx)); } diff --git a/service/client_state.cc b/service/client_state.cc index 789f80e261..3194b97e07 100644 --- a/service/client_state.cc +++ b/service/client_state.cc @@ -77,7 +77,7 @@ void service::client_state::validate_login() const { } } -void service::client_state::ensure_not_anonymous() const throw(exceptions::unauthorized_exception) { +void service::client_state::ensure_not_anonymous() const { validate_login(); if (_user->is_anonymous()) { throw exceptions::unauthorized_exception("You have to be logged in and not anonymous to perform this request"); diff --git a/service/client_state.hh b/service/client_state.hh index e97de77b5b..30ad1959f7 100644 --- a/service/client_state.hh +++ b/service/client_state.hh @@ -247,7 +247,7 @@ public: future<> ensure_has_permission(auth::permission, auth::data_resource) const; void validate_login() const; - void ensure_not_anonymous() const throw(exceptions::unauthorized_exception); + void ensure_not_anonymous() const; // unauthorized_exception on error #if 0 public void ensureIsSuper(String message) throws UnauthorizedException diff --git a/sstables/hyperloglog.hh b/sstables/hyperloglog.hh index b6e47f4ed9..c3ad93dc2b 100644 --- a/sstables/hyperloglog.hh +++ b/sstables/hyperloglog.hh @@ -250,7 +250,7 @@ public: * * @exception std::invalid_argument number of registers doesn't match. */ - void merge(const HyperLogLog& other) throw (std::invalid_argument) { + void merge(const HyperLogLog& other) { if (m_ != other.m_) { std::stringstream ss; ss << "number of registers doesn't match: " << m_ << " != " << other.m_; @@ -298,7 +298,7 @@ public: * * @exception std::runtime_error When failed to dump. */ - void dump(std::ostream& os) const throw(std::runtime_error){ + void dump(std::ostream& os) const { os.write((char*)&b_, sizeof(b_)); os.write((char*)&M_[0], sizeof(M_[0]) * M_.size()); if(os.fail()){ @@ -313,7 +313,7 @@ public: * * @exception std::runtime_error When failed to restore. */ - void restore(std::istream& is) throw(std::runtime_error){ + void restore(std::istream& is) { uint8_t b = 0; is.read((char*)&b, sizeof(b)); HyperLogLog tempHLL(b);