-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Ensure that IndexShard is mutable before force merges #122275
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import org.elasticsearch.action.ActionListener; | ||
| import org.elasticsearch.action.ActionRunnable; | ||
| import org.elasticsearch.action.support.ActionFilters; | ||
| import org.elasticsearch.action.support.SubscribableListener; | ||
| import org.elasticsearch.action.support.broadcast.BroadcastResponse; | ||
| import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; | ||
| import org.elasticsearch.cluster.ClusterState; | ||
|
|
@@ -92,12 +93,16 @@ protected void shardOperation( | |
| ActionListener<TransportBroadcastByNodeAction.EmptyResult> listener | ||
| ) { | ||
| assert (task instanceof CancellableTask) == false; // TODO: add cancellation handling here once the task supports it | ||
| threadPool.executor(ThreadPool.Names.FORCE_MERGE).execute(ActionRunnable.supply(listener, () -> { | ||
| SubscribableListener.<IndexShard>newForked(l -> { | ||
|
Contributor
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. Nit: seems to be neater to initialize indexShard and use IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()).getShard(shardRouting.shardId().id());
SubscribableListener.<Void>newForked(l -> indexShard.ensureMutable(l))
.<EmptyResult>andThen(l -> threadPool.executor(ThreadPool.Names.FORCE_MERGE).execute(ActionRunnable.supply(l, () -> {
indexShard.forceMerge(request);
return EmptyResult.INSTANCE;
})))
.addListener(listener);
Contributor
Author
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. We need to do the error handling when the index doesn't exist in the node anymore, that's why I included it in the listener. |
||
| IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()) | ||
| .getShard(shardRouting.shardId().id()); | ||
| indexShard.forceMerge(request); | ||
| return EmptyResult.INSTANCE; | ||
| })); | ||
| indexShard.ensureMutable(l.map(unused -> indexShard)); | ||
| }).<EmptyResult>andThen((l, indexShard) -> { | ||
kingherc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| threadPool.executor(ThreadPool.Names.FORCE_MERGE).execute(ActionRunnable.supply(l, () -> { | ||
| indexShard.forceMerge(request); | ||
kingherc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return EmptyResult.INSTANCE; | ||
| })); | ||
| }).addListener(listener); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.