Skip to content
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

Remove unnecessary index removal on index creation #8639

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -226,7 +226,7 @@ public void onFailure(String source, Throwable t) {

@Override
public ClusterState execute(ClusterState currentState) throws Exception {
boolean indexCreated = false;
boolean indexPartiallyCreated = false;
String failureReason = null;
try {
validate(request, currentState);
Expand Down Expand Up @@ -369,7 +369,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {

// create the index here (on the master) to validate it can be created, as well as adding the mapping
indicesService.createIndex(request.index(), actualIndexSettings, clusterService.localNode().id());
indexCreated = true;
indexPartiallyCreated = true;
// now add the mappings
IndexService indexService = indicesService.indexServiceSafe(request.index());
MapperService mapperService = indexService.mapperService();
Expand Down Expand Up @@ -466,9 +466,10 @@ public ClusterState execute(ClusterState currentState) throws Exception {
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(routingTableBuilder).build());
updatedState = ClusterState.builder(updatedState).routingResult(routingResult).build();
}
indexPartiallyCreated = false;
return updatedState;
} finally {
if (indexCreated) {
if (indexPartiallyCreated) {
// Index was already partially created - need to clean up
indicesService.removeIndex(request.index(), failureReason != null ? failureReason : "failed to create index");
}
Expand Down