Skip to content

Warn of change of default of wait_for_active_shards #67246

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 1 commit
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
13 changes: 12 additions & 1 deletion docs/reference/indices/close.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ Defaults to `open`.

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
`wait_for_active_shards`::
+
--
(Optional, string) The number of shard copies that must be active before
proceeding with the operation. Set to `all`, `index-setting`, or any positive
integer up to the total number of shards in the index (`number_of_replicas+1`).
The value `index-setting` means to wait according to the index setting
`index.write.wait_for_active_shards`. Default: `0`, meaning do not wait for any
shards to be ready.

See <<index-wait-for-active-shards>>.
--

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# Close index
- do:
indices.close:
wait_for_active_shards: 0
index : test_index

# Restore index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
# Close index
- do:
indices.close:
wait_for_active_shards: 0
index : test_index

# Restore index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"wait_for_active_shards":{
"type":"string",
"description":"Sets the number of active shards to wait for before the operation returns."
"description":"Sets the number of active shards to wait for before the operation returns. Set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. Defaults to `0`."
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_index

- do:
Expand Down Expand Up @@ -431,6 +432,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_index

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index-2
- is_true: acknowledged

Expand Down Expand Up @@ -106,6 +107,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index-2
- is_true: acknowledged

Expand Down Expand Up @@ -248,6 +250,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: bar

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index2
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index1

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_closed

- match: { acknowledged: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index-2
- is_true: acknowledged

Expand Down Expand Up @@ -257,6 +258,7 @@
# closing the index-2 does not change the cluster health with replicated closed indices
- do:
indices.close:
wait_for_active_shards: 0
index: index-2
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: index-2

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test_close_index

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test_index_3

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test_index_3

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test_index_2

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test-xyy

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_index
- is_true: acknowledged

Expand Down Expand Up @@ -51,6 +52,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_index
- is_true: acknowledged

Expand Down Expand Up @@ -111,10 +113,54 @@

- do:
indices.close:
wait_for_active_shards: 0
index: "index_*"

- match: { acknowledged: true }
- match: { shards_acknowledged: true }
- match: { indices.index_1.closed: true }
- match: { indices.index_2.closed: true }
- match: { indices.index_3.closed: true }

---
"?wait_for_active_shards=index-setting":
- skip:
version: " - 7.11.99"
reason: "?wait_for_active_shards=index-setting support added in 7.12"
features: ["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: "7.12.0 - "

---
"?wait_for_active_shards default is deprecated":
- skip:
version: " - 7.11.99"
reason: "required deprecation warning is only emitted in 7.12 and later"
features: ["warnings", "node_selector"]

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

- do:
indices.close:
index: "index_*"
node_selector:
version: "7.12.0 - "
warnings:
- "the default value for the ?wait_for_active_shards parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour"
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ setup:
"All indices":
- do:
indices.close:
wait_for_active_shards: 0
index: _all
- is_true: acknowledged

Expand Down Expand Up @@ -52,6 +53,7 @@ setup:
"Trailing wildcard":
- do:
indices.close:
wait_for_active_shards: 0
index: test_*
- is_true: acknowledged

Expand Down Expand Up @@ -79,6 +81,7 @@ setup:
"Only wildcard":
- do:
indices.close:
wait_for_active_shards: 0
index: '*'
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test-index

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: test_2
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index: test_index2

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index1

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: index_closed

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ setup:

- do:
indices.close:
wait_for_active_shards: 0
index : test_index

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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 @@ -37,6 +38,8 @@

public class RestCloseIndexAction extends BaseRestHandler {

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

@Override
public List<Route> routes() {
return unmodifiableList(asList(
Expand All @@ -56,7 +59,13 @@ 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 (waitForActiveShards == null) {
deprecationLogger.deprecate("close-index-wait_for_active_shards-default", "the default value for the ?wait_for_active_shards " +
"parameter will change from '0' to 'index-setting' in version 8; specify '?wait_for_active_shards=index-setting' " +
"to adopt the future default behaviour, or '?wait_for_active_shards=0' to preserve today's behaviour");
} else if ("index-setting".equalsIgnoreCase(waitForActiveShards)) {
closeIndexRequest.waitForActiveShards(ActiveShardCount.DEFAULT);
} else {
closeIndexRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
}
return channel -> client.admin().indices().close(closeIndexRequest, new RestToXContentListener<>(channel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,9 @@ protected static boolean indexExists(String index) throws IOException {
}

protected static void closeIndex(String index) throws IOException {
Response response = client().performRequest(new Request("POST", "/" + index + "/_close"));
assertThat(response.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
final Request closeRequest = new Request("POST", "/" + index + "/_close");
closeRequest.addParameter("wait_for_active_shards", "0");
assertOK(client().performRequest(closeRequest));
}

protected static void openIndex(String index) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: bar
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: follower_index
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

- do:
indices.close:
wait_for_active_shards: 0
index: bar
- is_true: acknowledged

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
# close request will not fail but will not match any data streams
- do:
indices.close:
wait_for_active_shards: 0
index: logs-*
- is_true: acknowledged
- length: { indices: 0 }
Expand Down Expand Up @@ -164,6 +165,7 @@
- do:
catch: bad_request
indices.close:
wait_for_active_shards: 0
index: ".ds-simple-data-stream1-*000001"

- do:
Expand Down
Loading