-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change priority for scheduling reroute during timeout #16445
base: main
Are you sure you want to change the base?
Changes from all commits
5e83a92
6a448d0
825a983
5368e7f
2ba604d
6e3b4d0
7329867
33ffefb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
@@ -82,6 +83,7 @@ public class ShardsBatchGatewayAllocator implements ExistingShardsAllocator { | |
|
||
private TimeValue primaryShardsBatchGatewayAllocatorTimeout; | ||
private TimeValue replicaShardsBatchGatewayAllocatorTimeout; | ||
private volatile Priority followUpRerouteTaskPriority; | ||
public static final TimeValue MIN_ALLOCATOR_TIMEOUT = TimeValue.timeValueSeconds(20); | ||
private final ClusterManagerMetrics clusterManagerMetrics; | ||
|
||
|
@@ -145,6 +147,32 @@ public void validate(TimeValue timeValue) { | |
Setting.Property.Dynamic | ||
); | ||
|
||
/** | ||
* Adjusts the priority of the followup reroute task when current round times out. NORMAL is right for reasonable clusters, | ||
* but for a cluster in a messed up state which is starving NORMAL priority tasks, it might be necessary to raise this higher | ||
* to allocate existing shards. | ||
*/ | ||
public static final Setting<Priority> FOLLOW_UP_REROUTE_PRIORITY_SETTING = new Setting<>( | ||
"cluster.routing.allocation.shards_batch_gateway_allocator.schedule_reroute.priority", | ||
Priority.NORMAL.toString(), | ||
ShardsBatchGatewayAllocator::parseReroutePriority, | ||
Setting.Property.NodeScope, | ||
Setting.Property.Dynamic | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic seems redundant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean to parse reroute priority? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
private static Priority parseReroutePriority(String priorityString) { | ||
final Priority priority = Priority.valueOf(priorityString.toUpperCase(Locale.ROOT)); | ||
switch (priority) { | ||
case NORMAL: | ||
case HIGH: | ||
case URGENT: | ||
return priority; | ||
} | ||
throw new IllegalArgumentException( | ||
"priority [" + priority + "] not supported for [" + FOLLOW_UP_REROUTE_PRIORITY_SETTING.getKey() + "]" | ||
); | ||
} | ||
|
||
private final RerouteService rerouteService; | ||
private final PrimaryShardBatchAllocator primaryShardBatchAllocator; | ||
private final ReplicaShardBatchAllocator replicaShardBatchAllocator; | ||
|
@@ -179,6 +207,8 @@ public ShardsBatchGatewayAllocator( | |
this.replicaShardsBatchGatewayAllocatorTimeout = REPLICA_BATCH_ALLOCATOR_TIMEOUT_SETTING.get(settings); | ||
clusterSettings.addSettingsUpdateConsumer(REPLICA_BATCH_ALLOCATOR_TIMEOUT_SETTING, this::setReplicaBatchAllocatorTimeout); | ||
this.clusterManagerMetrics = clusterManagerMetrics; | ||
setFollowUpRerouteTaskPriority(FOLLOW_UP_REROUTE_PRIORITY_SETTING.get(settings)); | ||
clusterSettings.addSettingsUpdateConsumer(FOLLOW_UP_REROUTE_PRIORITY_SETTING, this::setFollowUpRerouteTaskPriority); | ||
} | ||
|
||
@Override | ||
|
@@ -308,8 +338,8 @@ public void onComplete() { | |
logger.trace("scheduling reroute after existing shards allocator timed out for primary shards"); | ||
assert rerouteService != null; | ||
rerouteService.reroute( | ||
"reroute after existing shards allocator timed out", | ||
Priority.HIGH, | ||
"reroute after existing shards allocator [P] timed out", | ||
followUpRerouteTaskPriority, | ||
ActionListener.wrap( | ||
r -> logger.trace("reroute after existing shards allocator timed out completed"), | ||
e -> logger.debug("reroute after existing shards allocator timed out failed", e) | ||
|
@@ -343,8 +373,8 @@ public void onComplete() { | |
logger.trace("scheduling reroute after existing shards allocator timed out for replica shards"); | ||
assert rerouteService != null; | ||
rerouteService.reroute( | ||
"reroute after existing shards allocator timed out", | ||
Priority.HIGH, | ||
"reroute after existing shards allocator [R] timed out", | ||
followUpRerouteTaskPriority, | ||
ActionListener.wrap( | ||
r -> logger.trace("reroute after existing shards allocator timed out completed"), | ||
e -> logger.debug("reroute after existing shards allocator timed out failed", e) | ||
|
@@ -920,4 +950,8 @@ protected void setPrimaryBatchAllocatorTimeout(TimeValue primaryShardsBatchGatew | |
protected void setReplicaBatchAllocatorTimeout(TimeValue replicaShardsBatchGatewayAllocatorTimeout) { | ||
this.replicaShardsBatchGatewayAllocatorTimeout = replicaShardsBatchGatewayAllocatorTimeout; | ||
} | ||
|
||
protected void setFollowUpRerouteTaskPriority(Priority followUpRerouteTaskPriority) { | ||
this.followUpRerouteTaskPriority = followUpRerouteTaskPriority; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add a changelog as we are changing the default priority from HIGH to NORMAL