Files
scylladb/test/lib/alternator_test_env.cc
Kefu Chai 69c21f490a alternator,config: make alternator_timeout_in_ms live-updateable
before this change, alternator_timeout_in_ms is not live-updatable,
as after setting executor's default timeout right before creating
sharded executor instances, they never get updated with this option
anymore.

in this change,

* alternator_timeout_in_ms is marked as live-updateable
* executor::_s_default_timeout is changed to a thread_local variable,
  so it can be updated by a per-shard updateable_value. and
  it is now a updateable_value, so its variable name is updated
  accordingly. this value is set in the ctor of executor, and
  it is disconnected from the corresponding named_value<> option
  in the dtor of executor.
* alternator_timeout_in_ms is passed to the constructor of
  executor via sharded_parameter, so executor::_timeout_in_ms can
  be initialized on per-shard basis
* executor::set_default_timeout() is dropped, as we already pass
  the option to executor in its ctor.

please note, in the ctor of executor, we always update the cached
value of `s_default_timeout` with the value of `_timeout_in_ms`,
and we set the default timeout to 10s in `alternator_test_env`.
this is a design decision to avoid bending the production code for
testing, as in production, we always set the timeout with the value
specified either by the default value of yaml conf file.

Fixes #12232
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2023-03-23 20:57:08 +08:00

58 lines
1.7 KiB
C++

/*
* Copyright (C) 2021-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include "test/lib/alternator_test_env.hh"
#include "alternator/rmw_operation.hh"
#include "replica/database.hh"
#include <seastar/core/coroutine.hh>
#include "service/storage_proxy.hh"
using namespace std::chrono_literals;
future<> alternator_test_env::start(std::string_view isolation_level) {
smp_service_group_config c;
c.max_nonlocal_requests = 5000;
smp_service_group ssg = co_await create_smp_service_group(c);
utils::updateable_value<uint32_t> timeout_in_ms;
co_await _sdks.start(std::ref(_qp), std::ref(_mm), std::ref(_proxy));
co_await _cdc_metadata.start();
auto get_timeout_in_ms = sharded_parameter([] {
std::chrono::milliseconds ms = 10s;
return utils::updateable_value<uint32_t>(ms.count());
});
co_await _executor.start(
std::ref(_gossiper),
std::ref(_proxy),
std::ref(_mm),
// parameters below are only touched by alternator streams;
// not really interesting for this use case
std::ref(_sdks),
std::ref(_cdc_metadata),
// end-of-streams-parameters
ssg,
get_timeout_in_ms);
try {
alternator::rmw_operation::set_default_write_isolation(isolation_level);
} catch (const std::runtime_error& e) {
std::cout << e.what() << std::endl;
throw;
}
}
future<> alternator_test_env::stop() {
co_await _executor.stop();
co_await _cdc_metadata.stop();
co_await _sdks.stop();
}
future<> alternator_test_env::flush_memtables() {
return _proxy.local().get_db().invoke_on_all(&replica::database::flush_all_memtables);
}