remove RelocateShard::INVALID; add priority uniqueness check
This commit is contained in:
parent
e84fecf392
commit
d5a101a1eb
|
@ -67,65 +67,53 @@ inline bool isDataMovementForValleyFiller(DataMovementReason reason) {
|
||||||
reason == DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM;
|
reason == DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dataMovementPriority(DataMovementReason reason) {
|
typedef std::map<DataMovementReason, int> DmReasonPriorityMapping;
|
||||||
int priority;
|
typedef std::map<int, DataMovementReason> PriorityDmReasonMapping;
|
||||||
switch (reason) {
|
std::pair<const DmReasonPriorityMapping&, const PriorityDmReasonMapping&> buildPriorityMappings() {
|
||||||
case DataMovementReason::INVALID:
|
static DmReasonPriorityMapping reasonPriority{
|
||||||
priority = -1;
|
{ DataMovementReason::INVALID, -1 },
|
||||||
break;
|
{ DataMovementReason::RECOVER_MOVE, SERVER_KNOBS->PRIORITY_RECOVER_MOVE },
|
||||||
case DataMovementReason::RECOVER_MOVE:
|
{ DataMovementReason::REBALANCE_UNDERUTILIZED_TEAM, SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM },
|
||||||
priority = SERVER_KNOBS->PRIORITY_RECOVER_MOVE;
|
{ DataMovementReason::REBALANCE_OVERUTILIZED_TEAM, SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM },
|
||||||
break;
|
{ DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM, SERVER_KNOBS->PRIORITY_REBALANCE_READ_OVERUTIL_TEAM },
|
||||||
case DataMovementReason::REBALANCE_UNDERUTILIZED_TEAM:
|
{ DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM, SERVER_KNOBS->PRIORITY_REBALANCE_READ_UNDERUTIL_TEAM },
|
||||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_UNDERUTILIZED_TEAM;
|
{ DataMovementReason::PERPETUAL_STORAGE_WIGGLE, SERVER_KNOBS->PRIORITY_PERPETUAL_STORAGE_WIGGLE },
|
||||||
break;
|
{ DataMovementReason::TEAM_HEALTHY, SERVER_KNOBS->PRIORITY_TEAM_HEALTHY },
|
||||||
case DataMovementReason::REBALANCE_OVERUTILIZED_TEAM:
|
{ DataMovementReason::TEAM_CONTAINS_UNDESIRED_SERVER, SERVER_KNOBS->PRIORITY_TEAM_CONTAINS_UNDESIRED_SERVER },
|
||||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_OVERUTILIZED_TEAM;
|
{ DataMovementReason::TEAM_REDUNDANT, SERVER_KNOBS->PRIORITY_TEAM_REDUNDANT },
|
||||||
break;
|
{ DataMovementReason::MERGE_SHARD, SERVER_KNOBS->PRIORITY_MERGE_SHARD },
|
||||||
case DataMovementReason::REBALANCE_READ_OVERUTIL_TEAM:
|
{ DataMovementReason::POPULATE_REGION, SERVER_KNOBS->PRIORITY_POPULATE_REGION },
|
||||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_READ_OVERUTIL_TEAM;
|
{ DataMovementReason::TEAM_UNHEALTHY, SERVER_KNOBS->PRIORITY_TEAM_UNHEALTHY },
|
||||||
break;
|
{ DataMovementReason::TEAM_2_LEFT, SERVER_KNOBS->PRIORITY_TEAM_2_LEFT },
|
||||||
case DataMovementReason::REBALANCE_READ_UNDERUTIL_TEAM:
|
{ DataMovementReason::TEAM_1_LEFT, SERVER_KNOBS->PRIORITY_TEAM_1_LEFT },
|
||||||
priority = SERVER_KNOBS->PRIORITY_REBALANCE_READ_UNDERUTIL_TEAM;
|
{ DataMovementReason::TEAM_FAILED, SERVER_KNOBS->PRIORITY_TEAM_FAILED },
|
||||||
break;
|
{ DataMovementReason::TEAM_0_LEFT, SERVER_KNOBS->PRIORITY_TEAM_0_LEFT },
|
||||||
case DataMovementReason::PERPETUAL_STORAGE_WIGGLE:
|
{ DataMovementReason::SPLIT_SHARD, SERVER_KNOBS->PRIORITY_SPLIT_SHARD }
|
||||||
priority = SERVER_KNOBS->PRIORITY_PERPETUAL_STORAGE_WIGGLE;
|
};
|
||||||
break;
|
|
||||||
case DataMovementReason::TEAM_HEALTHY:
|
static PriorityDmReasonMapping priorityReason;
|
||||||
priority = SERVER_KNOBS->PRIORITY_TEAM_HEALTHY;
|
if (priorityReason.empty()) { // only build once
|
||||||
break;
|
for (const auto& [r, p] : reasonPriority) {
|
||||||
case DataMovementReason::TEAM_CONTAINS_UNDESIRED_SERVER:
|
priorityReason[p] = r;
|
||||||
priority = SERVER_KNOBS->PRIORITY_TEAM_CONTAINS_UNDESIRED_SERVER;
|
}
|
||||||
break;
|
// Don't allow 2 priorities value being the same.
|
||||||
case DataMovementReason::TEAM_REDUNDANT:
|
if (priorityReason.size() != reasonPriority.size()) {
|
||||||
priority = SERVER_KNOBS->PRIORITY_TEAM_REDUNDANT;
|
TraceEvent(SevError, "DuplicateDataMovementPriority").log();
|
||||||
break;
|
ASSERT(false);
|
||||||
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;
|
|
||||||
|
return std::make_pair(reasonPriority, priorityReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dataMovementPriority(DataMovementReason reason) {
|
||||||
|
const auto& [reasonPriority, _] = buildPriorityMappings();
|
||||||
|
return reasonPriority.at(reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
DataMovementReason priorityToDataMovementReason(int priority) {
|
||||||
|
const auto& [_, priorityReason] = buildPriorityMappings();
|
||||||
|
return priorityReason.at(priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RelocateData {
|
struct RelocateData {
|
||||||
|
@ -148,7 +136,7 @@ struct RelocateData {
|
||||||
std::shared_ptr<DataMove> dataMove;
|
std::shared_ptr<DataMove> dataMove;
|
||||||
|
|
||||||
RelocateData()
|
RelocateData()
|
||||||
: priority(-1), boundaryPriority(-1), healthPriority(-1), reason(RelocateReason::INVALID), startTime(-1),
|
: priority(-1), boundaryPriority(-1), healthPriority(-1), reason(RelocateReason::OTHER), startTime(-1),
|
||||||
dataMoveId(anonymousShardId), workFactor(0), wantsNewServers(false), cancellable(false),
|
dataMoveId(anonymousShardId), workFactor(0), wantsNewServers(false), cancellable(false),
|
||||||
interval("QueuedRelocation") {}
|
interval("QueuedRelocation") {}
|
||||||
explicit RelocateData(RelocateShard const& rs)
|
explicit RelocateData(RelocateShard const& rs)
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include "flow/actorcompiler.h" // This must be the last #include.
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
||||||
|
|
||||||
enum class RelocateReason { INVALID = -1, OTHER, REBALANCE_DISK, REBALANCE_READ };
|
enum class RelocateReason { OTHER = 0, REBALANCE_DISK, REBALANCE_READ };
|
||||||
|
|
||||||
// One-to-one relationship to the priority knobs
|
// One-to-one relationship to the priority knobs
|
||||||
enum class DataMovementReason {
|
enum class DataMovementReason {
|
||||||
|
@ -59,11 +59,11 @@ enum class DataMovementReason {
|
||||||
TEAM_0_LEFT,
|
TEAM_0_LEFT,
|
||||||
SPLIT_SHARD
|
SPLIT_SHARD
|
||||||
};
|
};
|
||||||
|
extern int dataMovementPriority(DataMovementReason moveReason);
|
||||||
|
extern DataMovementReason priorityToDataMovementReason(int priority);
|
||||||
|
|
||||||
struct DDShardInfo;
|
struct DDShardInfo;
|
||||||
|
|
||||||
extern int dataMovementPriority(DataMovementReason moveReason);
|
|
||||||
|
|
||||||
// Represents a data move in DD.
|
// Represents a data move in DD.
|
||||||
struct DataMove {
|
struct DataMove {
|
||||||
DataMove() : meta(DataMoveMetaData()), restore(false), valid(false), cancelled(false) {}
|
DataMove() : meta(DataMoveMetaData()), restore(false), valid(false), cancelled(false) {}
|
||||||
|
@ -95,7 +95,7 @@ struct RelocateShard {
|
||||||
RelocateReason reason;
|
RelocateReason reason;
|
||||||
DataMovementReason moveReason;
|
DataMovementReason moveReason;
|
||||||
RelocateShard()
|
RelocateShard()
|
||||||
: priority(0), cancelled(false), dataMoveId(anonymousShardId), reason(RelocateReason::INVALID),
|
: priority(0), cancelled(false), dataMoveId(anonymousShardId), reason(RelocateReason::OTHER),
|
||||||
moveReason(DataMovementReason::INVALID) {}
|
moveReason(DataMovementReason::INVALID) {}
|
||||||
RelocateShard(KeyRange const& keys, DataMovementReason moveReason, RelocateReason reason)
|
RelocateShard(KeyRange const& keys, DataMovementReason moveReason, RelocateReason reason)
|
||||||
: keys(keys), cancelled(false), dataMoveId(anonymousShardId), reason(reason), moveReason(moveReason) {
|
: keys(keys), cancelled(false), dataMoveId(anonymousShardId), reason(reason), moveReason(moveReason) {
|
||||||
|
|
Loading…
Reference in New Issue