database: don't copy config object

Copying the config object breaks the link between the original and the copied
object, so updates to config items will not be visible. To allow updates, don't
copy any more, and instead keep a pointer.

The pointer won't work will once config is updateable, since the same object is
shared across multiple shard, but that can be addressed later.
This commit is contained in:
Avi Kivity
2019-04-06 17:30:49 +03:00
parent 339699b627
commit fe59997efe
3 changed files with 6 additions and 6 deletions

View File

@@ -118,7 +118,7 @@ thread_local dirty_memory_manager default_dirty_memory_manager;
inline
flush_controller
make_flush_controller(db::config& cfg, seastar::scheduling_group sg, const ::io_priority_class& iop, std::function<double()> fn) {
make_flush_controller(const db::config& cfg, seastar::scheduling_group sg, const ::io_priority_class& iop, std::function<double()> fn) {
if (cfg.memtable_flush_static_shares() > 0) {
return flush_controller(sg, iop, cfg.memtable_flush_static_shares());
}
@@ -127,7 +127,7 @@ make_flush_controller(db::config& cfg, seastar::scheduling_group sg, const ::io_
inline
std::unique_ptr<compaction_manager>
make_compaction_manager(db::config& cfg, database_config& dbcfg) {
make_compaction_manager(const db::config& cfg, database_config& dbcfg) {
if (cfg.compaction_static_shares() > 0) {
return std::make_unique<compaction_manager>(dbcfg.compaction_scheduling_group, service::get_local_compaction_priority(), dbcfg.available_memory, cfg.compaction_static_shares());
}
@@ -182,7 +182,7 @@ utils::UUID database::empty_version = utils::UUID_gen::get_name_UUID(bytes{});
database::database(const db::config& cfg, database_config dbcfg)
: _stats(make_lw_shared<db_stats>())
, _cl_stats(std::make_unique<cell_locker_stats>())
, _cfg(std::make_unique<db::config>(cfg))
, _cfg(&cfg)
// Allow system tables a pool of 10 MB memory to write, but never block on other regions.
, _system_dirty_memory_manager(*this, 10 << 20, cfg.virtual_dirty_soft_limit(), default_scheduling_group())
, _dirty_memory_manager(*this, dbcfg.available_memory * 0.45, cfg.virtual_dirty_soft_limit(), dbcfg.statement_scheduling_group)

View File

@@ -1233,7 +1233,7 @@ private:
lw_shared_ptr<db_stats> _stats;
std::unique_ptr<cell_locker_stats> _cl_stats;
std::unique_ptr<db::config> _cfg;
const db::config* _cfg;
dirty_memory_manager _system_dirty_memory_manager;
dirty_memory_manager _dirty_memory_manager;

View File

@@ -335,7 +335,7 @@ public:
auto wait_for_background_jobs = defer([] { sstables::await_background_jobs_on_all_shards().get(); });
auto db = ::make_shared<distributed<database>>();
auto cfg = make_lw_shared<db::config>(*cfg_in.db_config);
auto cfg = cfg_in.db_config;
tmpdir data_dir;
auto data_dir_path = data_dir.path().string();
if (!cfg->data_file_directories.is_set()) {
@@ -388,7 +388,7 @@ public:
database_config dbcfg;
dbcfg.available_memory = memory::stats().total_memory();
db->start(std::move(*cfg), dbcfg).get();
db->start(std::ref(*cfg), dbcfg).get();
auto stop_db = defer([db] {
db->stop().get();
});