Use enum variables to invoke Priority checking (#7514)
* Use enum variables to invoke Priority checking * add an explicit isDataMovementForReadBalancing function
This commit is contained in:
parent
407300bfa6
commit
9c20b15f5a
|
@ -41,20 +41,100 @@
|
|||
typedef Reference<IDataDistributionTeam> ITeamRef;
|
||||
typedef std::pair<ITeamRef, ITeamRef> SrcDestTeamPair;
|
||||
|
||||
// TODO: add guard to guarantee the priority is not equal for each purpose?
|
||||
// FIXME: Always use DataMovementReason to invoke these functions.
|
||||
inline bool isDiskRebalancePriority(int priority) {
|
||||
return priority == SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM ||
|
||||
priority == SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM;
|
||||
}
|
||||
|
||||
inline bool isDataMovementForDiskBalancing(DataMovementReason reason) {
|
||||
return reason == DataMovementReason::REBALANCE_UNDERUTILIZED_TEAM ||
|
||||
reason == DataMovementReason::REBALANCE_OVERUTILIZED_TEAM;
|
||||
}
|
||||
|
||||
inline bool isDataMovementForReadBalancing(DataMovementReason reason) {
|
||||
return reason == DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM ||
|
||||
reason == DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM;
|
||||
}
|
||||
|
||||
inline bool isMountainChopperPriority(int priority) {
|
||||
return priority == SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM ||
|
||||
priority == SERVER_KNOBS->PRIORITY_REBALANCE_READ_OVERUTIL_TEAM;
|
||||
}
|
||||
|
||||
inline bool isDataMovementForMountainChopper(DataMovementReason reason) {
|
||||
return reason == DataMovementReason::REBALANCE_OVERUTILIZED_TEAM ||
|
||||
reason == DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM;
|
||||
}
|
||||
|
||||
inline bool isValleyFillerPriority(int priority) {
|
||||
return priority == SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM ||
|
||||
priority == SERVER_KNOBS->PRIORITY_REBALANCE_READ_UNDERUTIL_TEAM;
|
||||
}
|
||||
|
||||
inline bool isDataMovementForValleyFiller(DataMovementReason reason) {
|
||||
return reason == DataMovementReason::REBALANCE_UNDERUTILIZED_TEAM ||
|
||||
reason == DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM;
|
||||
}
|
||||
|
||||
int dataMovementPriority(DataMovementReason reason) {
|
||||
int priority;
|
||||
switch (reason) {
|
||||
case DataMovementReason::RECOVER_MOVE:
|
||||
priority = SERVER_KNOBS->PRIORITY_RECOVER_MOVE;
|
||||
break;
|
||||
case DataMovementReason::REBALANCE_UNDERUTILIZED_TEAM:
|
||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM;
|
||||
break;
|
||||
case DataMovementReason::REBALANCE_OVERUTILIZED_TEAM:
|
||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM;
|
||||
break;
|
||||
case DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM:
|
||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_READ_OVERUTIL_TEAM;
|
||||
break;
|
||||
case DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM:
|
||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_READ_UNDERUTIL_TEAM;
|
||||
break;
|
||||
case DataMovementReason::PERPETUAL_STORAGE_WIGGLE:
|
||||
priority = SERVER_KNOBS->PRIORITY_PERPETUAL_STORAGE_WIGGLE;
|
||||
break;
|
||||
case DataMovementReason::TEAM_HEALTHY:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_HEALTHY;
|
||||
break;
|
||||
case DataMovementReason::TEAM_CONTAINS_UNDESIRED_SERVER:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_CONTAINS_UNDESIRED_SERVER;
|
||||
break;
|
||||
case DataMovementReason::TEAM_REDUNDANT:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_REDUNDANT;
|
||||
break;
|
||||
case DataMovementReason::MERGE_SHARD:
|
||||
priority = SERVER_KNOBS->PRIORITY_MERGE_SHARD;
|
||||
break;
|
||||
case DataMovementReason::POPULATE_REGION:
|
||||
priority = SERVER_KNOBS->PRIORITY_POPULATE_REGION;
|
||||
break;
|
||||
case DataMovementReason::TEAM_UNHEALTHY:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_UNHEALTHY;
|
||||
break;
|
||||
case DataMovementReason::TEAM_2_LEFT:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_2_LEFT;
|
||||
break;
|
||||
case DataMovementReason::TEAM_1_LEFT:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_1_LEFT;
|
||||
break;
|
||||
case DataMovementReason::TEAM_FAILED:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_FAILED;
|
||||
break;
|
||||
case DataMovementReason::TEAM_0_LEFT:
|
||||
priority = SERVER_KNOBS->PRIORITY_TEAM_0_LEFT;
|
||||
break;
|
||||
case DataMovementReason::SPLIT_SHARD:
|
||||
priority = SERVER_KNOBS->PRIORITY_SPLIT_SHARD;
|
||||
break;
|
||||
}
|
||||
return priority;
|
||||
}
|
||||
|
||||
struct RelocateData {
|
||||
KeyRange keys;
|
||||
int priority;
|
||||
|
@ -1842,16 +1922,16 @@ ACTOR Future<SrcDestTeamPair> getSrcDestTeams(DDQueueData* self,
|
|||
return {};
|
||||
}
|
||||
|
||||
ACTOR Future<Void> BgDDLoadRebalance(DDQueueData* self, int teamCollectionIndex, int ddPriority) {
|
||||
ACTOR Future<Void> BgDDLoadRebalance(DDQueueData* self, int teamCollectionIndex, DataMovementReason reason) {
|
||||
state int resetCount = SERVER_KNOBS->DD_REBALANCE_RESET_AMOUNT;
|
||||
state Transaction tr(self->cx);
|
||||
state double lastRead = 0;
|
||||
state bool skipCurrentLoop = false;
|
||||
state Future<Void> delayF = Never();
|
||||
state const bool readRebalance = !isDiskRebalancePriority(ddPriority);
|
||||
state const bool readRebalance = isDataMovementForReadBalancing(reason);
|
||||
state const char* eventName =
|
||||
isMountainChopperPriority(ddPriority) ? "BgDDMountainChopper_New" : "BgDDValleyFiller_New";
|
||||
|
||||
isDataMovementForMountainChopper(reason) ? "BgDDMountainChopper_New" : "BgDDValleyFiller_New";
|
||||
state int ddPriority = dataMovementPriority(reason);
|
||||
loop {
|
||||
state bool moved = false;
|
||||
state Reference<IDataDistributionTeam> sourceTeam;
|
||||
|
@ -1899,7 +1979,7 @@ ACTOR Future<Void> BgDDLoadRebalance(DDQueueData* self, int teamCollectionIndex,
|
|||
traceEvent.detail("QueuedRelocations", self->priority_relocations[ddPriority]);
|
||||
|
||||
if (self->priority_relocations[ddPriority] < SERVER_KNOBS->DD_REBALANCE_PARALLELISM) {
|
||||
if (isMountainChopperPriority(ddPriority)) {
|
||||
if (isDataMovementForMountainChopper(reason)) {
|
||||
srcReq = GetTeamRequest(WantNewServers::True,
|
||||
WantTrueBest::True,
|
||||
PreferLowerDiskUtil::False,
|
||||
|
@ -2197,10 +2277,8 @@ ACTOR Future<Void> dataDistributionQueue(Database cx,
|
|||
// balancingFutures.push_back(BgDDLoadRebalance(&self, i, SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM));
|
||||
// balancingFutures.push_back(BgDDLoadRebalance(&self, i, SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM));
|
||||
if (SERVER_KNOBS->READ_SAMPLING_ENABLED) {
|
||||
balancingFutures.push_back(
|
||||
BgDDLoadRebalance(&self, i, SERVER_KNOBS->PRIORITY_REBALANCE_READ_OVERUTIL_TEAM));
|
||||
balancingFutures.push_back(
|
||||
BgDDLoadRebalance(&self, i, SERVER_KNOBS->PRIORITY_REBALANCE_READ_UNDERUTIL_TEAM));
|
||||
balancingFutures.push_back(BgDDLoadRebalance(&self, i, DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM));
|
||||
balancingFutures.push_back(BgDDLoadRebalance(&self, i, DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM));
|
||||
}
|
||||
balancingFutures.push_back(BgDDMountainChopper(&self, i));
|
||||
balancingFutures.push_back(BgDDValleyFiller(&self, i));
|
||||
|
|
|
@ -37,6 +37,27 @@
|
|||
|
||||
enum class RelocateReason { INVALID = -1, OTHER, REBALANCE_DISK, REBALANCE_READ };
|
||||
|
||||
// One-to-one relationship to the priority knobs
|
||||
enum class DataMovementReason {
|
||||
RECOVER_MOVE,
|
||||
REBALANCE_UNDERUTILIZED_TEAM,
|
||||
REBALANCE_OVERUTILIZED_TEAM,
|
||||
REBALANCE_READ_OVERUTIL_TEAM,
|
||||
REBALANCE_READ_UNDERUTIL_TEAM,
|
||||
PERPETUAL_STORAGE_WIGGLE,
|
||||
TEAM_HEALTHY,
|
||||
TEAM_CONTAINS_UNDESIRED_SERVER,
|
||||
TEAM_REDUNDANT,
|
||||
MERGE_SHARD,
|
||||
POPULATE_REGION,
|
||||
TEAM_UNHEALTHY,
|
||||
TEAM_2_LEFT,
|
||||
TEAM_1_LEFT,
|
||||
TEAM_FAILED,
|
||||
TEAM_0_LEFT,
|
||||
SPLIT_SHARD
|
||||
};
|
||||
|
||||
struct DDShardInfo;
|
||||
|
||||
// Represents a data move in DD.
|
||||
|
|
Loading…
Reference in New Issue