From ca44f4de3cd9e4239147fb86afef4cc1d5982061 Mon Sep 17 00:00:00 2001 From: Jesse Haber-Kucharsky Date: Mon, 30 Jul 2018 21:32:18 -0400 Subject: [PATCH] Use finite query time-outs for `system_distributed` --- db/system_distributed_keyspace.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/db/system_distributed_keyspace.cc b/db/system_distributed_keyspace.cc index 8bb2cfe46c..8f562c3de0 100644 --- a/db/system_distributed_keyspace.cc +++ b/db/system_distributed_keyspace.cc @@ -26,6 +26,7 @@ #include "db/consistency_level_type.hh" #include "db/system_keyspace.hh" #include "schema_builder.hh" +#include "timeout_config.hh" #include "types.hh" #include @@ -97,11 +98,17 @@ future<> system_distributed_keyspace::stop() { return make_ready_future<>(); } +static const timeout_config internal_distributed_timeout_config = [] { + using namespace std::chrono_literals; + const auto t = 10s; + return timeout_config{ t, t, t, t, t, t, t }; +}(); + future> system_distributed_keyspace::view_status(sstring ks_name, sstring view_name) const { return _qp.process( sprint("SELECT host_id, status FROM %s.%s WHERE keyspace_name = ? AND view_name = ?", NAME, VIEW_BUILD_STATUS), db::consistency_level::ONE, - infinite_timeout_config, + internal_distributed_timeout_config, { std::move(ks_name), std::move(view_name) }, false).then([this] (::shared_ptr cql_result) { return boost::copy_range>(*cql_result @@ -118,7 +125,7 @@ future<> system_distributed_keyspace::start_view_build(sstring ks_name, sstring return _qp.process( sprint("INSERT INTO %s.%s (keyspace_name, view_name, host_id, status) VALUES (?, ?, ?, ?)", NAME, VIEW_BUILD_STATUS), db::consistency_level::ONE, - infinite_timeout_config, + internal_distributed_timeout_config, { std::move(ks_name), std::move(view_name), std::move(host_id), "STARTED" }, false).discard_result(); }); @@ -129,7 +136,7 @@ future<> system_distributed_keyspace::finish_view_build(sstring ks_name, sstring return _qp.process( sprint("UPDATE %s.%s SET status = ? WHERE keyspace_name = ? AND view_name = ? AND host_id = ?", NAME, VIEW_BUILD_STATUS), db::consistency_level::ONE, - infinite_timeout_config, + internal_distributed_timeout_config, { "SUCCESS", std::move(ks_name), std::move(view_name), std::move(host_id) }, false).discard_result(); }); @@ -139,7 +146,7 @@ future<> system_distributed_keyspace::remove_view(sstring ks_name, sstring view_ return _qp.process( sprint("DELETE FROM %s.%s WHERE keyspace_name = ? AND view_name = ?", NAME, VIEW_BUILD_STATUS), db::consistency_level::ONE, - infinite_timeout_config, + internal_distributed_timeout_config, { std::move(ks_name), std::move(view_name) }, false).discard_result(); }