Skip to content

Introduce ?wait_for_active_shards=index-setting #67158

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/reference/migration/migrate_8_0/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,18 @@ Discontinue use of the `index.translog.retention.age` and
`index.translog.retention.size` index settings. Requests that
include these settings will return an error.
====

.The default for the `?wait_for_active_shards` parameter on the close index API has changed.
[%collapsible]
====
*Details* +
When closing an index in earlier versions, by default {es} would not wait for
the shards of the closed index to be properly assigned before returning. From
version 8.0 onwards the default behaviour is to wait for shards to be assigned
according to the <<index-wait-for-active-shards,index setting
`index.write.wait_for_active_shards`>>.

*Impact* +
Accept the new behaviour, or specify `?wait_for_active_shards=0` to preserve
the old behaviour if needed.
====
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
- match: { shards_acknowledged: true }
---
"Close index response with result per index":
- skip:
version: " - 7.2.99"
reason: "close index response reports result per index starting version 7.3.0"

- do:
indices.create:
index: index_1
Expand Down Expand Up @@ -115,3 +111,26 @@
- match: { indices.index_1.closed: true }
- match: { indices.index_2.closed: true }
- match: { indices.index_3.closed: true }

---
"?wait_for_active_shards=index-setting is deprecated":
- skip:
version: " - 7.99.99"
reason: "required deprecation warning is only emitted in 8.0 and later"
features: ["warnings", "node_selector"]

- do:
indices.create:
index: index_1
body:
settings:
number_of_replicas: 0

- do:
indices.close:
index: "index_*"
wait_for_active_shards: index-setting
node_selector:
version: "8.0.0 - "
warnings:
- "?wait_for_active_shards=index-setting is now the default behaviour; the 'index-setting' value for this parameter should no longer be used since it will become unsupported in version 9"
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

package org.elasticsearch.rest.action.admin.indices;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
Expand All @@ -35,6 +37,8 @@

public class RestCloseIndexAction extends BaseRestHandler {

private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestCloseIndexAction.class);

@Override
public List<Route> routes() {
return List.of(
Expand All @@ -54,7 +58,17 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
String waitForActiveShards = request.param("wait_for_active_shards");
if (waitForActiveShards != null) {
if ("index-setting".equalsIgnoreCase(waitForActiveShards)) {
deprecationLogger.deprecate("close-index-wait_for_active_shards-index-setting",
"?wait_for_active_shards=index-setting is now the default behaviour; the 'index-setting' value for this parameter " +
"should no longer be used since it will become unsupported in version " + (Version.V_7_0_0.major + 2));
// TODO in v9:
// - throw an IllegalArgumentException here
// - record the removal of support for this value as a breaking change.
// - mention Version.V_8_0_0 in the code to ensure that we revisit this in v10
// TODO in v10:
// - remove the IllegalArgumentException here
} else if (waitForActiveShards != null) {
closeIndexRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
}
return channel -> client.admin().indices().close(closeIndexRequest, new RestToXContentListener<>(channel));
Expand Down