From 79d5511149f221b6baf54250dd89276fd8b0736b Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 13 Mar 2020 17:49:02 -0700 Subject: [PATCH 1/2] A "proxy" class process would not be preferred as the "first proxy" for restore and DR purposes --- fdbserver/ClusterController.actor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index 5cbc6ebb8a..fe6ce12961 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -696,8 +696,8 @@ public: auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies()-1, req.configuration, id_used, first_proxy ); auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers()-1, req.configuration, id_used, first_resolver ); - proxies.push_back(first_proxy.worker); - resolvers.push_back(first_resolver.worker); + proxies.insert(proxies.begin(), first_proxy.worker); + resolvers.insert(resolvers.begin(), first_resolver.worker); for(int i = 0; i < resolvers.size(); i++) result.resolvers.push_back(resolvers[i].interf); @@ -829,8 +829,8 @@ public: auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies()-1, req.configuration, used, first_proxy ); auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers()-1, req.configuration, used, first_resolver ); - proxies.push_back(first_proxy.worker); - resolvers.push_back(first_resolver.worker); + proxies.insert(proxies.begin(), first_proxy.worker); + resolvers.insert(resolvers.begin(), first_resolver.worker); RoleFitnessPair fitness( RoleFitness(proxies, ProcessClass::Proxy), RoleFitness(resolvers, ProcessClass::Resolver) ); @@ -1137,8 +1137,8 @@ public: auto proxies = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Proxy, db.config.getDesiredProxies()-1, db.config, id_used, first_proxy, true ); auto resolvers = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Resolver, db.config.getDesiredResolvers()-1, db.config, id_used, first_resolver, true ); - proxies.push_back(first_proxy.worker); - resolvers.push_back(first_resolver.worker); + proxies.insert(proxies.begin(), first_proxy.worker); + resolvers.insert(resolvers.begin(), first_resolver.worker); RoleFitnessPair newInFit(RoleFitness(proxies, ProcessClass::Proxy), RoleFitness(resolvers, ProcessClass::Resolver)); if(oldInFit.proxy.betterFitness(newInFit.proxy) || oldInFit.resolver.betterFitness(newInFit.resolver)) { From 012344e2979cd681986f2f2927392b3f23a1090b Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Mon, 16 Mar 2020 11:50:17 -0700 Subject: [PATCH 2/2] refactor getWorkersForRoleInDatacenter --- fdbserver/ClusterController.actor.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/fdbserver/ClusterController.actor.cpp b/fdbserver/ClusterController.actor.cpp index fe6ce12961..72a9681c9f 100644 --- a/fdbserver/ClusterController.actor.cpp +++ b/fdbserver/ClusterController.actor.cpp @@ -484,8 +484,12 @@ public: vector getWorkersForRoleInDatacenter(Optional> const& dcId, ProcessClass::ClusterRole role, int amount, DatabaseConfiguration const& conf, std::map< Optional>, int>& id_used, Optional minWorker = Optional(), bool checkStable = false ) { std::map, std::pair,vector>> fitness_workers; vector results; - if (amount <= 0) + if(minWorker.present()) { + results.push_back(minWorker.get().worker); + } + if (amount <= results.size()) { return results; + } for( auto& it : id_worker ) { auto fitness = it.second.details.processClass.machineClassFitness( role ); @@ -693,11 +697,8 @@ public: auto first_resolver = getWorkerForRoleInDatacenter( dcId, ProcessClass::Resolver, ProcessClass::ExcludeFit, req.configuration, id_used ); auto first_proxy = getWorkerForRoleInDatacenter( dcId, ProcessClass::Proxy, ProcessClass::ExcludeFit, req.configuration, id_used ); - auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies()-1, req.configuration, id_used, first_proxy ); - auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers()-1, req.configuration, id_used, first_resolver ); - - proxies.insert(proxies.begin(), first_proxy.worker); - resolvers.insert(resolvers.begin(), first_resolver.worker); + auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies(), req.configuration, id_used, first_proxy ); + auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers(), req.configuration, id_used, first_resolver ); for(int i = 0; i < resolvers.size(); i++) result.resolvers.push_back(resolvers[i].interf); @@ -826,11 +827,8 @@ public: auto first_resolver = getWorkerForRoleInDatacenter( dcId, ProcessClass::Resolver, ProcessClass::ExcludeFit, req.configuration, used ); auto first_proxy = getWorkerForRoleInDatacenter( dcId, ProcessClass::Proxy, ProcessClass::ExcludeFit, req.configuration, used ); - auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies()-1, req.configuration, used, first_proxy ); - auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers()-1, req.configuration, used, first_resolver ); - - proxies.insert(proxies.begin(), first_proxy.worker); - resolvers.insert(resolvers.begin(), first_resolver.worker); + auto proxies = getWorkersForRoleInDatacenter( dcId, ProcessClass::Proxy, req.configuration.getDesiredProxies(), req.configuration, used, first_proxy ); + auto resolvers = getWorkersForRoleInDatacenter( dcId, ProcessClass::Resolver, req.configuration.getDesiredResolvers(), req.configuration, used, first_resolver ); RoleFitnessPair fitness( RoleFitness(proxies, ProcessClass::Proxy), RoleFitness(resolvers, ProcessClass::Resolver) ); @@ -1135,10 +1133,8 @@ public: auto first_resolver = getWorkerForRoleInDatacenter( clusterControllerDcId, ProcessClass::Resolver, ProcessClass::ExcludeFit, db.config, id_used, true ); auto first_proxy = getWorkerForRoleInDatacenter( clusterControllerDcId, ProcessClass::Proxy, ProcessClass::ExcludeFit, db.config, id_used, true ); - auto proxies = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Proxy, db.config.getDesiredProxies()-1, db.config, id_used, first_proxy, true ); - auto resolvers = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Resolver, db.config.getDesiredResolvers()-1, db.config, id_used, first_resolver, true ); - proxies.insert(proxies.begin(), first_proxy.worker); - resolvers.insert(resolvers.begin(), first_resolver.worker); + auto proxies = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Proxy, db.config.getDesiredProxies(), db.config, id_used, first_proxy, true ); + auto resolvers = getWorkersForRoleInDatacenter( clusterControllerDcId, ProcessClass::Resolver, db.config.getDesiredResolvers(), db.config, id_used, first_resolver, true ); RoleFitnessPair newInFit(RoleFitness(proxies, ProcessClass::Proxy), RoleFitness(resolvers, ProcessClass::Resolver)); if(oldInFit.proxy.betterFitness(newInFit.proxy) || oldInFit.resolver.betterFitness(newInFit.resolver)) {