Data movement's resource control: Do not overload servers used for the RelocateData return true if servers are not too busy to launch the relocation This ensure source servers will not be overloaded.
| 419 | // return true if servers are not too busy to launch the relocation |
| 420 | // This ensure source servers will not be overloaded. |
| 421 | bool canLaunchSrc(RelocateData& relocation, |
| 422 | int teamSize, |
| 423 | int singleRegionTeamSize, |
| 424 | std::map<UID, Busyness>& busymap, |
| 425 | std::vector<RelocateData> cancellableRelocations) { |
| 426 | // assert this has not already been launched |
| 427 | ASSERT(relocation.workFactor == 0); |
| 428 | ASSERT(relocation.src.size() != 0); |
| 429 | ASSERT(teamSize >= singleRegionTeamSize); |
| 430 | |
| 431 | // find the "workFactor" for this, were it launched now |
| 432 | int workFactor = getSrcWorkFactor(relocation, singleRegionTeamSize); |
| 433 | int neededServers = std::min<int>(relocation.src.size(), teamSize - singleRegionTeamSize + 1); |
| 434 | if (SERVER_KNOBS->USE_OLD_NEEDED_SERVERS) { |
| 435 | neededServers = std::max(1, (int)relocation.src.size() - teamSize + 1); |
| 436 | } |
| 437 | // see if each of the SS can launch this task |
| 438 | for (int i = 0; i < relocation.src.size(); i++) { |
| 439 | // For each source server for this relocation, copy and modify its busyness to reflect work that WOULD be |
| 440 | // cancelled |
| 441 | auto busyCopy = busymap[relocation.src[i]]; |
| 442 | for (int j = 0; j < cancellableRelocations.size(); j++) { |
| 443 | auto& servers = cancellableRelocations[j].src; |
| 444 | if (std::count(servers.begin(), servers.end(), relocation.src[i])) |
| 445 | busyCopy.removeWork(cancellableRelocations[j].priority, cancellableRelocations[j].workFactor); |
| 446 | } |
| 447 | // Use this modified busyness to check if this relocation could be launched |
| 448 | if (busyCopy.canLaunch(relocation.priority, workFactor)) { |
| 449 | --neededServers; |
| 450 | if (neededServers == 0) |
| 451 | return true; |
| 452 | } |
| 453 | } |
| 454 | return false; |
| 455 | } |
| 456 | |
| 457 | // candidateTeams is a vector containing one team per datacenter, the team(s) DD is planning on moving the shard to. |
| 458 | bool canLaunchDest(const std::vector<std::pair<Reference<IDataDistributionTeam>, bool>>& candidateTeams, |
no test coverage detected