-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Simplify delayed shard allocation #18351
Conversation
@bleskes can you have a look? |
@@ -59,18 +54,13 @@ | |||
private final AllocationService allocationService; | |||
|
|||
private AtomicBoolean rerouting = new AtomicBoolean(); | |||
private volatile long minDelaySettingAtLastSchedulingNanos = Long.MAX_VALUE; | |||
private volatile ScheduledFuture registeredNextDelayFuture; | |||
|
|||
@Inject | |||
public RoutingService(Settings settings, ThreadPool threadPool, ClusterService clusterService, AllocationService allocationService) { | |||
super(settings); | |||
this.threadPool = threadPool; |
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 don't need the thread pool anymore
@bleskes I've updated the PR. Please have another look. |
if (earlierRerouteNeeded) { | ||
logger.info("scheduling reroute for delayed shards in [{}] ({} delayed shards)", nextDelay, | ||
UnassignedInfo.getNumberOfDelayedUnassigned(state)); | ||
newTask.schedule(); |
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.
I'm thinking some more about scheduling first and making it visible second and having second doubts on that one. Looking at the code again , why do we need to schedule first/what's the down side of doing it after setting delayedRerouteTask, so we know removeTaskAndCancel/removeIfSameTask work?
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.
Yes, we can do it the other way around. We know that close will be run after scheduleIfNeeded, and never the other way around.
Looking good! left comments here and there. Almost all very minor. |
@bleskes thanks for reviewing. I've updated the PR with your suggestions. Please have another look. |
LGTM. @ywelsch thanks for the extra iterations |
c7eeb27
to
2369748
Compare
2369748
to
45e8798
Compare
This PR simplifies the delayed shard allocation implementation by assigning clear responsibilities to the various components that are affected by delayed shard allocation:
UnassignedInfo
gets a boolean flagdelayed
which determines whether assignment of the shard should be delayed. The flag gets persisted in the cluster state and is thus available across nodes, i.e. each node knows whether a shard was delayed-unassigned in a specific cluster state. Before, nodes other than the current master were unaware of that information.true
if the shard becomes unassigned due to a node leaving and the index settingindex.unassigned.node_left.delayed_timeout
being strictly positive. From then on, unassigned shards can only transition from delayed to non-delayed, never in the other direction.DelayedAllocationService
, reacting to cluster change events, has the responsibility to schedule reroutes to remove the delay marker.Relates to #18293