From a45ecaf33647651cfc5983f620ebc74921461763 Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Sun, 6 Mar 2016 17:22:48 +0200 Subject: [PATCH 1/2] database: store "incremental backup" configuration value in per-shard instance Store the "incremental_backups" configuration value in the database class (and use it when creating a keyspace::config) in order to be able to modify it in runtime. Signed-off-by: Vlad Zolotarov --- database.cc | 3 ++- database.hh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/database.cc b/database.cc index c30abb9e36..ffe854335b 100644 --- a/database.cc +++ b/database.cc @@ -1028,6 +1028,7 @@ database::database() : database(db::config()) database::database(const db::config& cfg) : _cfg(std::make_unique(cfg)) , _version(empty_version) + , _enable_incremental_backups(cfg.incremental_backups()) { _memtable_total_space = size_t(_cfg->memtable_total_space_in_mb()) << 20; if (!_memtable_total_space) { @@ -1834,7 +1835,7 @@ database::make_keyspace_config(const keyspace_metadata& ksm) { } cfg.dirty_memory_region_group = &_dirty_memory_region_group; cfg.cf_stats = &_cf_stats; - cfg.enable_incremental_backups = _cfg->incremental_backups(); + cfg.enable_incremental_backups = _enable_incremental_backups; return cfg; } diff --git a/database.hh b/database.hh index 1224d49696..ce2f8df980 100644 --- a/database.hh +++ b/database.hh @@ -570,6 +570,7 @@ class database { std::vector _collectd; timer<> _throttling_timer{[this] { unthrottle(); }}; circular_buffer> _throttled_requests; + bool _enable_incremental_backups = false; future<> init_commitlog(); future<> apply_in_memory(const frozen_mutation& m, const schema_ptr& m_schema, const db::replay_position&); @@ -589,6 +590,8 @@ private: public: static utils::UUID empty_version; + void set_enable_incremental_backups(bool val) { _enable_incremental_backups = val; } + future<> parse_system_tables(distributed&); database(); database(const db::config&); From 2cd836a02e2d357d8d525a36c6fffab46ae199bb Mon Sep 17 00:00:00 2001 From: Vlad Zolotarov Date: Sun, 6 Mar 2016 17:26:31 +0200 Subject: [PATCH 2/2] api::set_storage_service(): fix the 'nodetool enablebackup' API 'nodetool enable/disablebackup' callback was modifying only the existing keyspaces and column families configurations. However new keyspaces/column families were using the original 'incremental_backups' configuration value which could be different from the value configured by 'nodetool enable/disablebackup' user command. This patch updates the database::_enable_incremental_backups per-shard value in addition to updating the existing keyspaces and column families configurations. Fixes #845 Signed-off-by: Vlad Zolotarov --- api/storage_service.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/storage_service.cc b/api/storage_service.cc index 2c5097ef3b..74ac261dc1 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -588,6 +588,8 @@ void set_storage_service(http_context& ctx, routes& r) { auto val_str = req->get_query_param("value"); bool value = (val_str == "True") || (val_str == "true") || (val_str == "1"); return service::get_local_storage_service().db().invoke_on_all([value] (database& db) { + db.set_enable_incremental_backups(value); + // Change both KS and CF, so they are in sync for (auto& pair: db.get_keyspaces()) { auto& ks = pair.second;