Skip to content

Commit 4eb76f5

Browse files
committed
Re-resolve indices
1 parent c27246b commit 4eb76f5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.rest.action.cat;
2121

22-
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2322
import org.elasticsearch.action.ActionListener;
2423
import org.elasticsearch.action.ActionResponse;
2524
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
@@ -106,18 +105,20 @@ public RestResponse buildResponse(final Table table) throws Exception {
106105
sendGetSettingsRequest(indices, indicesOptions, local, masterNodeTimeout, client, new ActionListener<>() {
107106
@Override
108107
public void onResponse(final GetSettingsResponse getSettingsResponse) {
109-
final String[] concreteIndices = new String[getSettingsResponse.getIndexToSettings().size()];
110-
int i = 0;
111-
for(ObjectObjectCursor<String, Settings> cursor : getSettingsResponse.getIndexToSettings()) {
112-
concreteIndices[i++] = cursor.key;
113-
}
114-
115108
final GroupedActionListener<ActionResponse> groupedListener = createGroupedListener(request, 4, listener);
116109
groupedListener.onResponse(getSettingsResponse);
117110

118-
sendIndicesStatsRequest(concreteIndices, indicesOptions, includeUnloadedSegments, client, groupedListener);
119-
sendClusterStateRequest(concreteIndices, indicesOptions, local, masterNodeTimeout, client, groupedListener);
120-
sendClusterHealthRequest(concreteIndices, indicesOptions, local, masterNodeTimeout, client, groupedListener);
111+
// Indices that were successfully resolved during the get settings request might be deleted when the subsequent cluster
112+
// state, cluster health and indices stats requests execute. We have to distinguish two cases:
113+
// 1) the deleted index was explicitly passed as parameter to the /_cat/indices request. In this case we want the
114+
// subsequent requests to fail.
115+
// 2) the deleted index was resolved as part of a wildcard or _all. In this case, we want the subsequent requests not to
116+
// fail on the deleted index (as we want to ignore wildcards that cannot be resolved).
117+
// This behavior can be ensured by letting the cluster state, cluster health and indices stats requests re-resolve the
118+
// index names with the same indices options that we used for the initial cluster state request (strictExpand).
119+
sendIndicesStatsRequest(indices, indicesOptions, includeUnloadedSegments, client, groupedListener);
120+
sendClusterStateRequest(indices, indicesOptions, local, masterNodeTimeout, client, groupedListener);
121+
sendClusterHealthRequest(indices, indicesOptions, local, masterNodeTimeout, client, groupedListener);
121122
}
122123

123124
@Override

0 commit comments

Comments
 (0)