Skip to content

Commit

Permalink
cql3: use timeout config from client state instead of query options
Browse files Browse the repository at this point in the history
... in batch statement, in order to be able to remove the timeout
from query options later.
  • Loading branch information
psarna committed Feb 25, 2021
1 parent 639d90d commit f973e09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cql3/statements/batch_statement.cc
Expand Up @@ -59,8 +59,8 @@ timeout_for_type(batch_statement::type t) {
: &timeout_config::write_timeout;
}

db::timeout_clock::duration batch_statement::get_timeout(const query_options& options) const {
return _attrs->is_timeout_set() ? _attrs->get_timeout(options) : options.get_timeout_config().*get_timeout_config_selector();
db::timeout_clock::duration batch_statement::get_timeout(const service::client_state& state, const query_options& options) const {
return _attrs->is_timeout_set() ? _attrs->get_timeout(options) : state.get_timeout_config().*get_timeout_config_selector();
}

batch_statement::batch_statement(int bound_terms, type type_,
Expand Down Expand Up @@ -290,7 +290,7 @@ future<shared_ptr<cql_transport::messages::result_message>> batch_statement::do_
++_stats.batches;
_stats.statements_in_batches += _statements.size();

auto timeout = db::timeout_clock::now() + get_timeout(options);
auto timeout = db::timeout_clock::now() + get_timeout(query_state.get_client_state(), options);
return get_mutations(storage, options, timeout, local, now, query_state).then([this, &storage, &options, timeout, tr_state = query_state.get_trace_state(),
permit = query_state.get_permit()] (std::vector<mutation> ms) mutable {
return execute_without_conditions(storage, std::move(ms), options.get_consistency(), timeout, std::move(tr_state), std::move(permit));
Expand Down Expand Up @@ -347,7 +347,7 @@ future<shared_ptr<cql_transport::messages::result_message>> batch_statement::exe
schema_ptr schema;

db::timeout_clock::time_point now = db::timeout_clock::now();
const timeout_config& cfg = options.get_timeout_config();
const timeout_config& cfg = qs.get_client_state().get_timeout_config();
auto batch_timeout = now + cfg.write_timeout; // Statement timeout.
auto cas_timeout = now + cfg.cas_timeout; // Ballot contention timeout.
auto read_timeout = now + cfg.read_timeout; // Query timeout.
Expand Down
2 changes: 1 addition & 1 deletion cql3/statements/batch_statement.hh
Expand Up @@ -171,7 +171,7 @@ private:
const query_options& options,
service::query_state& state) const;

db::timeout_clock::duration get_timeout(const query_options& options) const;
db::timeout_clock::duration get_timeout(const service::client_state& state, const query_options& options) const;
public:
// FIXME: no cql_statement::to_string() yet
#if 0
Expand Down

0 comments on commit f973e09

Please sign in to comment.