workload prioritization: Fix configuration change detection

The configuration detection is based on a loop that
advances two iterators and compares the two collection
for deducing the configuration change. In order to
correctly deduce the changes the iteration have to be
according to the key (service level name) order for both
of the collections. If it doesn't happen the results are
undefined and in some cases can lead to a crash of the
system. The bug is that the _service_level_db field was
implemented using an unordered_map which obviously don't
guarantie the configuration change detection assumption.
The fix was simply to change the field type to a map
instead of unordered_map.

Another problem is that when a static service level (i.e
default) is at the end of the keys list, it is repeatedly
being deleted - which doesn't really do anything since deleting
a static service level is just retaining it's defult values
but it is stil wrong.
This commit is contained in:
Eliran Sinvani
2021-04-23 10:20:19 +02:00
committed by Piotr Sarna
parent 946fc6af08
commit 02d37cb133
2 changed files with 4 additions and 2 deletions

View File

@@ -175,7 +175,9 @@ future<> service_level_controller::update_service_levels_from_distributed_data()
for (; current_it != _service_levels_db.end(); current_it++) {
sl_logger.info("service level \"{}\" was deleted.", current_it->first.c_str());
service_levels_for_delete.emplace(current_it->first, current_it->second.slo);
if (!current_it->second.is_static) {
service_levels_for_delete.emplace(current_it->first, current_it->second.slo);
}
}
for (; new_state_it != service_levels.end(); new_state_it++) {
sl_logger.info("service level \"{}\" was added.", new_state_it->first.c_str());

View File

@@ -85,7 +85,7 @@ private:
static constexpr shard_id global_controller = 0;
std::unordered_map<sstring, service_level> _service_levels_db;
std::map<sstring, service_level> _service_levels_db;
std::unordered_map<sstring, sstring> _role_to_service_level;
service_level _default_service_level;
service_level_distributed_data_accessor_ptr _sl_data_accessor;