From 4a36d5cd79d9937c07951bf1de3ea74433fbeab3 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Tue, 26 Oct 2021 06:37:56 -0500 Subject: [PATCH] Remove endpoint for freezing indices (#78918) --- .../elasticsearch/client/IndicesClientIT.java | 29 +-- .../IndicesClientDocumentationIT.java | 97 +-------- docs/java-rest/redirects.asciidoc | 8 + .../data-streams/data-streams.asciidoc | 1 - .../reference/ilm/actions/ilm-freeze.asciidoc | 34 ---- .../actions/ilm-searchable-snapshot.asciidoc | 2 +- docs/reference/ilm/ilm-actions.asciidoc | 4 - .../ilm/ilm-index-lifecycle.asciidoc | 1 - docs/reference/ilm/ilm-overview.asciidoc | 11 +- docs/reference/indices.asciidoc | 8 +- docs/reference/indices/apis/freeze.asciidoc | 62 ------ docs/reference/indices/apis/unfreeze.asciidoc | 22 ++- docs/reference/indices/index-mgmt.asciidoc | 8 +- docs/reference/indices/resolve.asciidoc | 3 - .../params/eager-global-ordinals.asciidoc | 7 - docs/reference/redirects.asciidoc | 36 +++- .../long-running-searches.asciidoc | 3 +- .../search-your-data.asciidoc | 3 +- docs/reference/sql/endpoints/jdbc.asciidoc | 2 +- docs/reference/sql/language/indices.asciidoc | 6 +- .../rest-api-spec/api/indices.freeze.json | 67 ------- x-pack/plugin/build.gradle | 5 + .../rest/action/RestFreezeIndexAction.java | 8 +- ...stractSearchableSnapshotsRestTestCase.java | 38 +--- .../multi-cluster-with-security/build.gradle | 2 + .../sql/qa/server/multi-node/build.gradle | 1 + .../sql/qa/server/security/build.gradle | 1 + .../sql/qa/server/single-node/build.gradle | 2 + .../xpack/sql/qa/jdbc/DataLoader.java | 8 - .../test/indices.freeze/10_basic.yml | 186 ------------------ .../test/indices.freeze/20_stats.yml | 67 ------- .../test/indices.freeze/30_usage.yml | 65 ------ x-pack/qa/freeze-plugin/build.gradle | 25 +++ .../plugin/freeze/FreezeIndexPlugin.java | 85 ++++++++ .../xpack/restart/FullClusterRestartIT.java | 68 +------ 35 files changed, 205 insertions(+), 770 deletions(-) delete mode 100644 docs/reference/ilm/actions/ilm-freeze.asciidoc delete mode 100644 docs/reference/indices/apis/freeze.asciidoc delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.freeze.json delete mode 100644 x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/10_basic.yml delete mode 100644 x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/20_stats.yml delete mode 100644 x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/30_usage.yml create mode 100644 x-pack/qa/freeze-plugin/build.gradle create mode 100644 x-pack/qa/freeze-plugin/src/main/java/org/elasticsearch/plugin/freeze/FreezeIndexPlugin.java diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 77e4a0e0d3800..8e7783db95ad1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -42,7 +42,6 @@ import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.broadcast.BroadcastResponse; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.core.ShardsAcknowledgedResponse; import org.elasticsearch.client.indices.AnalyzeRequest; import org.elasticsearch.client.indices.AnalyzeResponse; import org.elasticsearch.client.indices.CloseIndexRequest; @@ -58,7 +57,6 @@ import org.elasticsearch.client.indices.DeleteAliasRequest; import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest; import org.elasticsearch.client.indices.DeleteDataStreamRequest; -import org.elasticsearch.client.indices.FreezeIndexRequest; import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest; import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse; import org.elasticsearch.client.indices.GetDataStreamRequest; @@ -80,7 +78,6 @@ import org.elasticsearch.client.indices.ReloadAnalyzersResponse; import org.elasticsearch.client.indices.SimulateIndexTemplateRequest; import org.elasticsearch.client.indices.SimulateIndexTemplateResponse; -import org.elasticsearch.client.indices.UnfreezeIndexRequest; import org.elasticsearch.client.indices.rollover.RolloverRequest; import org.elasticsearch.client.indices.rollover.RolloverResponse; import org.elasticsearch.cluster.metadata.AliasMetadata; @@ -95,16 +92,16 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.core.TimeValue; -import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xcontent.XContentType; -import org.elasticsearch.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.support.XContentMapValues; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentType; +import org.elasticsearch.xcontent.json.JsonXContent; import java.io.IOException; import java.util.Arrays; @@ -1535,24 +1532,6 @@ public void testAnalyze() throws Exception { assertNotNull(detailsResponse.detail()); } - public void testFreezeAndUnfreeze() throws IOException { - createIndex("test", Settings.EMPTY); - RestHighLevelClient client = highLevelClient(); - - final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder() - .setWarningsHandler(warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING).equals(warnings) == false).build(); - - ShardsAcknowledgedResponse freeze = execute(new FreezeIndexRequest("test"), client.indices()::freeze, - client.indices()::freezeAsync, freezeIndexOptions); - assertTrue(freeze.isShardsAcknowledged()); - assertTrue(freeze.isAcknowledged()); - - ShardsAcknowledgedResponse unfreeze = execute(new UnfreezeIndexRequest("test"), client.indices()::unfreeze, - client.indices()::unfreezeAsync, freezeIndexOptions); - assertTrue(unfreeze.isShardsAcknowledged()); - assertTrue(unfreeze.isAcknowledged()); - } - public void testReloadAnalyzer() throws IOException { createIndex("test", Settings.EMPTY); RestHighLevelClient client = highLevelClient(); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java index e40cef14ba4d6..3dac417e5244c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java @@ -55,22 +55,21 @@ import org.elasticsearch.client.indices.DeleteAliasRequest; import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest; import org.elasticsearch.client.indices.DetailAnalyzeResponse; -import org.elasticsearch.client.indices.FreezeIndexRequest; +import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest; +import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse; import org.elasticsearch.client.indices.GetFieldMappingsRequest; import org.elasticsearch.client.indices.GetFieldMappingsResponse; import org.elasticsearch.client.indices.GetIndexRequest; import org.elasticsearch.client.indices.GetIndexResponse; -import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest; import org.elasticsearch.client.indices.GetIndexTemplatesRequest; import org.elasticsearch.client.indices.GetIndexTemplatesResponse; -import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse; import org.elasticsearch.client.indices.GetMappingsRequest; import org.elasticsearch.client.indices.GetMappingsResponse; import org.elasticsearch.client.indices.IndexTemplateMetadata; import org.elasticsearch.client.indices.IndexTemplatesExistRequest; import org.elasticsearch.client.indices.PutComponentTemplateRequest; -import org.elasticsearch.client.indices.PutIndexTemplateRequest; import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest; +import org.elasticsearch.client.indices.PutIndexTemplateRequest; import org.elasticsearch.client.indices.PutMappingRequest; import org.elasticsearch.client.indices.ReloadAnalyzersRequest; import org.elasticsearch.client.indices.ReloadAnalyzersResponse; @@ -90,13 +89,13 @@ import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.TimeValue; -import org.elasticsearch.xcontent.XContentBuilder; -import org.elasticsearch.xcontent.XContentFactory; -import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.xcontent.XContentBuilder; +import org.elasticsearch.xcontent.XContentFactory; +import org.elasticsearch.xcontent.XContentType; import java.io.IOException; import java.util.Collections; @@ -108,7 +107,6 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.client.IndicesClientIT.FROZEN_INDICES_DEPRECATION_WARNING; -import static org.elasticsearch.client.IndicesClientIT.IGNORE_THROTTLED_DEPRECATION_WARNING; import static org.elasticsearch.client.IndicesClientIT.LEGACY_TEMPLATE_OPTIONS; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; @@ -2874,89 +2872,6 @@ public void onFailure(Exception e) { } - public void testFreezeIndex() throws Exception { - RestHighLevelClient client = highLevelClient(); - - { - CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT); - assertTrue(createIndexResponse.isAcknowledged()); - } - - { - // tag::freeze-index-request - FreezeIndexRequest request = new FreezeIndexRequest("index"); // <1> - // end::freeze-index-request - - // tag::freeze-index-request-timeout - request.setTimeout(TimeValue.timeValueMinutes(2)); // <1> - // end::freeze-index-request-timeout - // tag::freeze-index-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> - // end::freeze-index-request-masterTimeout - // tag::freeze-index-request-waitForActiveShards - request.setWaitForActiveShards(ActiveShardCount.DEFAULT); // <1> - // end::freeze-index-request-waitForActiveShards - - // tag::freeze-index-request-indicesOptions - request.setIndicesOptions(IndicesOptions.strictExpandOpen()); // <1> - // end::freeze-index-request-indicesOptions - - final RequestOptions freezeIndexOptions = RequestOptions.DEFAULT.toBuilder() - .setWarningsHandler( - warnings -> List.of(FROZEN_INDICES_DEPRECATION_WARNING, IGNORE_THROTTLED_DEPRECATION_WARNING).equals(warnings) == false - ).build(); - - // tag::freeze-index-execute - ShardsAcknowledgedResponse openIndexResponse = client.indices().freeze(request, freezeIndexOptions); - // end::freeze-index-execute - - // tag::freeze-index-response - boolean acknowledged = openIndexResponse.isAcknowledged(); // <1> - boolean shardsAcked = openIndexResponse.isShardsAcknowledged(); // <2> - // end::freeze-index-response - assertTrue(acknowledged); - assertTrue(shardsAcked); - - // tag::freeze-index-execute-listener - ActionListener listener = - new ActionListener() { - @Override - public void onResponse(ShardsAcknowledgedResponse freezeIndexResponse) { - // <1> - } - - @Override - public void onFailure(Exception e) { - // <2> - } - }; - // end::freeze-index-execute-listener - - // Replace the empty listener by a blocking listener in test - final CountDownLatch latch = new CountDownLatch(1); - listener = new LatchedActionListener<>(listener, latch); - - // tag::freeze-index-execute-async - client.indices().freezeAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::freeze-index-execute-async - - assertTrue(latch.await(30L, TimeUnit.SECONDS)); - } - - { - // tag::freeze-index-notfound - try { - FreezeIndexRequest request = new FreezeIndexRequest("does_not_exist"); - client.indices().freeze(request, RequestOptions.DEFAULT); - } catch (ElasticsearchException exception) { - if (exception.status() == RestStatus.BAD_REQUEST) { - // <1> - } - } - // end::freeze-index-notfound - } - } - public void testUnfreezeIndex() throws Exception { RestHighLevelClient client = highLevelClient(); diff --git a/docs/java-rest/redirects.asciidoc b/docs/java-rest/redirects.asciidoc index a077102b405d4..37f331a87bcef 100644 --- a/docs/java-rest/redirects.asciidoc +++ b/docs/java-rest/redirects.asciidoc @@ -47,3 +47,11 @@ See <>. === Stop {transform} API See <>. + +[role="exclude",id="java-rest-high-freeze-index"] +=== Freeze index API + +The freeze index API was removed in 8.0. Frozen indices are no longer useful due +to +https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent +improvements in heap memory usage]. diff --git a/docs/reference/data-streams/data-streams.asciidoc b/docs/reference/data-streams/data-streams.asciidoc index 4e124e9b8055a..25e084e6e7c42 100644 --- a/docs/reference/data-streams/data-streams.asciidoc +++ b/docs/reference/data-streams/data-streams.asciidoc @@ -67,7 +67,6 @@ such as: * <> * <> -* <> * <> * <> diff --git a/docs/reference/ilm/actions/ilm-freeze.asciidoc b/docs/reference/ilm/actions/ilm-freeze.asciidoc deleted file mode 100644 index db413545c0910..0000000000000 --- a/docs/reference/ilm/actions/ilm-freeze.asciidoc +++ /dev/null @@ -1,34 +0,0 @@ -[role="xpack"] -[[ilm-freeze]] -=== Freeze - -Phases allowed: cold. - -<> an index. - -deprecated[7.x,"The ILM Freeze action was deprecated in 7.x and will be treated as a no-op in 8.0+."] - -[[ilm-freeze-options]] -==== Options - -None. - -[[ilm-freeze-ex]] -==== Example - -[source,console] --------------------------------------------------- -PUT _ilm/policy/my_policy -{ - "policy": { - "phases": { - "cold": { - "actions": { - "freeze" : { } - } - } - } - } -} --------------------------------------------------- - diff --git a/docs/reference/ilm/actions/ilm-searchable-snapshot.asciidoc b/docs/reference/ilm/actions/ilm-searchable-snapshot.asciidoc index 428d071c1e36a..fa4a32f8b6a17 100644 --- a/docs/reference/ilm/actions/ilm-searchable-snapshot.asciidoc +++ b/docs/reference/ilm/actions/ilm-searchable-snapshot.asciidoc @@ -18,7 +18,7 @@ index>> to the frozen tier. In other phases, the action mounts a <> to the corresponding data tier. If the `searchable_snapshot` action is used in the hot phase the subsequent -phases cannot include the `shrink`, `forcemerge`, or `freeze` actions. +phases cannot include the `shrink` or `forcemerge` actions. This action cannot be performed on a data stream's write index. Attempts to do so will fail. To convert the index to a searchable snapshot, first diff --git a/docs/reference/ilm/ilm-actions.asciidoc b/docs/reference/ilm/ilm-actions.asciidoc index 4b3e456d00230..cbe6923e3cd0d 100644 --- a/docs/reference/ilm/ilm-actions.asciidoc +++ b/docs/reference/ilm/ilm-actions.asciidoc @@ -14,9 +14,6 @@ Permanently remove the index. Reduce the number of index segments and purge deleted documents. Makes the index read-only. -<>:: -Freeze the index to minimize its memory footprint. - <>:: Move the index shards to the <> that corresponds to the current {ilm-init} phase. @@ -49,7 +46,6 @@ Ensure that a snapshot exists before deleting the index. include::actions/ilm-allocate.asciidoc[] include::actions/ilm-delete.asciidoc[] include::actions/ilm-forcemerge.asciidoc[] -include::actions/ilm-freeze.asciidoc[] include::actions/ilm-migrate.asciidoc[] include::actions/ilm-readonly.asciidoc[] include::actions/ilm-rollover.asciidoc[] diff --git a/docs/reference/ilm/ilm-index-lifecycle.asciidoc b/docs/reference/ilm/ilm-index-lifecycle.asciidoc index a6f5fd755bf54..9f5e871cb2ad4 100644 --- a/docs/reference/ilm/ilm-index-lifecycle.asciidoc +++ b/docs/reference/ilm/ilm-index-lifecycle.asciidoc @@ -106,7 +106,6 @@ actions in the order listed. - <> - <> - <> - - <> * Frozen - <> * Delete diff --git a/docs/reference/ilm/ilm-overview.asciidoc b/docs/reference/ilm/ilm-overview.asciidoc index bc00a43bcabff..fa65d91d6e7f7 100644 --- a/docs/reference/ilm/ilm-overview.asciidoc +++ b/docs/reference/ilm/ilm-overview.asciidoc @@ -7,8 +7,8 @@ Overview ++++ -You can create and apply {ilm-cap} ({ilm-init}) policies to automatically manage your indices -according to your performance, resiliency, and retention requirements. +You can create and apply {ilm-cap} ({ilm-init}) policies to automatically manage your indices +according to your performance, resiliency, and retention requirements. Index lifecycle policies can trigger actions such as: @@ -17,7 +17,6 @@ size, number of docs, or age. * **Shrink**: Reduces the number of primary shards in an index. * **Force merge**: Triggers a <> to reduce the number of segments in an index's shards. -* **Freeze**: <> an index and makes it read-only. * **Delete**: Permanently remove an index, including all of its data and metadata. @@ -48,9 +47,9 @@ hardware. [IMPORTANT] =========================== -To use {ilm-init}, all nodes in a cluster must run the same version. -Although it might be possible to create and apply policies in a mixed-version cluster, +To use {ilm-init}, all nodes in a cluster must run the same version. +Although it might be possible to create and apply policies in a mixed-version cluster, there is no guarantee they will work as intended. Attempting to use a policy that contains actions that aren't -supported on all nodes in a cluster will cause errors. +supported on all nodes in a cluster will cause errors. =========================== diff --git a/docs/reference/indices.asciidoc b/docs/reference/indices.asciidoc index 650a6239cdbab..335757c8a1813 100644 --- a/docs/reference/indices.asciidoc +++ b/docs/reference/indices.asciidoc @@ -18,7 +18,6 @@ index settings, aliases, mappings, and index templates. * <> * <> * <> -* <> * <> * <> @@ -53,9 +52,9 @@ index settings, aliases, mappings, and index templates. === Index templates: Index templates automatically apply settings, mappings, and aliases to new indices. -They are most often used to configure rolling indices for time series data to -ensure that each new index has the same configuration as the previous one. -The index template associated with a data stream configures its backing indices. +They are most often used to configure rolling indices for time series data to +ensure that each new index has the same configuration as the previous one. +The index template associated with a data stream configures its backing indices. For more information, see <>. * <> @@ -113,7 +112,6 @@ include::indices/indices-exists.asciidoc[] include::indices/field-usage-stats.asciidoc[] include::indices/flush.asciidoc[] include::indices/forcemerge.asciidoc[] -include::indices/apis/freeze.asciidoc[] include::indices/get-alias.asciidoc[] include::indices/get-component-template.asciidoc[] include::indices/get-field-mapping.asciidoc[] diff --git a/docs/reference/indices/apis/freeze.asciidoc b/docs/reference/indices/apis/freeze.asciidoc deleted file mode 100644 index 2a18939fbf1bd..0000000000000 --- a/docs/reference/indices/apis/freeze.asciidoc +++ /dev/null @@ -1,62 +0,0 @@ -[role="xpack"] -[testenv="basic"] -[[freeze-index-api]] -=== Freeze index API -++++ -Freeze index -++++ - -// tag::freeze-api-dep[] -deprecated::[7.14, Frozen indices are no longer useful due to https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent improvements in heap memory usage].] -// end::freeze-api-dep[] - -Freezes an index. - -[[freeze-index-api-request]] -==== {api-request-title} - -`POST //_freeze` - -[[freeze-index-api-prereqs]] -==== {api-prereq-title} - -* If the {es} {security-features} are enabled, you must have the `manage` -<> for the target index or index alias. - -[[freeze-index-api-desc]] -==== {api-description-title} - -A frozen index has almost no overhead on the cluster (except for maintaining its -metadata in memory) and is read-only. Read-only indices are blocked for write -operations, such as <> or <>. See <>. - -The current write index on a data stream cannot be frozen. In order to freeze -the current write index, the data stream must first be -<> so that a new write index is created -and then the previous write index can be frozen. - -IMPORTANT: Freezing an index will close the index and reopen it within the same -API call. This causes primaries to not be allocated for a short amount of time -and causes the cluster to go red until the primaries are allocated again. This -limitation might be removed in the future. - -[[freeze-index-api-path-parms]] -==== {api-path-parms-title} - -``:: - (Required, string) Identifier for the index. - -[[freeze-index-api-examples]] -==== {api-examples-title} - -The following example freezes and unfreezes an index: - -[source,console] --------------------------------------------------- -POST /my-index-000001/_freeze -POST /my-index-000001/_unfreeze --------------------------------------------------- -// TEST[skip:unable to ignore deprecation warning] -// TEST[s/^/PUT my-index-000001\n/] - diff --git a/docs/reference/indices/apis/unfreeze.asciidoc b/docs/reference/indices/apis/unfreeze.asciidoc index 5176faf8bce97..e9869316dbb72 100644 --- a/docs/reference/indices/apis/unfreeze.asciidoc +++ b/docs/reference/indices/apis/unfreeze.asciidoc @@ -6,7 +6,17 @@ Unfreeze index ++++ -deprecated::[7.14, Frozen indices are no longer useful due to https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent improvements in heap memory usage].] +[WARNING] +.Deprecated in 7.14 +==== +In 8.0, we removed the ability to freeze an index. In previous versions, +freezing an index reduced its memory overhead. However, frozen indices are no +longer useful due to +https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent +improvements in heap memory usage]. +You can use this API to unfreeze indices that were frozen in 7.x. Frozen indices +are not related to the frozen data tier. +==== Unfreezes an index. @@ -25,12 +35,7 @@ Unfreezes an index. ==== {api-description-title} When a frozen index is unfrozen, the index goes through the normal recovery -process and becomes writeable again. See <>. - -IMPORTANT: Freezing an index will close the index and reopen it within the same -API call. This causes primaries to not be allocated for a short amount of time -and causes the cluster to go red until the primaries are allocated again. This -limitation might be removed in the future. +process and becomes writeable again. [[unfreeze-index-api-path-parms]] ==== {api-path-parms-title} @@ -41,11 +46,10 @@ limitation might be removed in the future. [[unfreeze-index-api-examples]] ==== {api-examples-title} -The following example freezes and unfreezes an index: +The following example unfreezes an index: [source,console] -------------------------------------------------- -POST /my-index-000001/_freeze POST /my-index-000001/_unfreeze -------------------------------------------------- // TEST[s/^/PUT my-index-000001\n/] diff --git a/docs/reference/indices/index-mgmt.asciidoc b/docs/reference/indices/index-mgmt.asciidoc index 0543da9b2a562..5bbb2044ca082 100644 --- a/docs/reference/indices/index-mgmt.asciidoc +++ b/docs/reference/indices/index-mgmt.asciidoc @@ -15,7 +15,7 @@ You'll learn how to: * View and edit index settings. * View mappings and statistics for an index. -* Perform index-level operations, such as refreshes and freezes. +* Perform index-level operations, such as refreshes. * View and manage data streams. * Create index templates to automatically configure new data streams and indices. @@ -43,9 +43,8 @@ Open {kib}'s main menu and click *Stack Management > Index Management*. image::images/index-mgmt/management_index_labels.png[Index Management UI] The *Index Management* page contains an overview of your indices. -Badges indicate if an index is <>, a -<>, or a -<>. +Badges indicate if an index is a <>, a +<>, or <>. Clicking a badge narrows the list to only indices of that type. You can also filter indices using the search bar. @@ -68,7 +67,6 @@ indices on the overview page. The menu includes the following actions: * <> * <> * <> -* <> * <> * *Add* <> diff --git a/docs/reference/indices/resolve.asciidoc b/docs/reference/indices/resolve.asciidoc index 7f9c29dd1bcd3..b946949eb53c2 100644 --- a/docs/reference/indices/resolve.asciidoc +++ b/docs/reference/indices/resolve.asciidoc @@ -18,8 +18,6 @@ PUT /remotecluster-bar-01 PUT /freeze-index -POST /freeze-index/_freeze - PUT /my-index-000001 PUT /freeze-index/_alias/f-alias @@ -110,7 +108,6 @@ The API returns the following response: "f-alias" ], "attributes": [ - "frozen", "open" ] }, diff --git a/docs/reference/mapping/params/eager-global-ordinals.asciidoc b/docs/reference/mapping/params/eager-global-ordinals.asciidoc index 27c6f94183134..b09e3eae783c8 100644 --- a/docs/reference/mapping/params/eager-global-ordinals.asciidoc +++ b/docs/reference/mapping/params/eager-global-ordinals.asciidoc @@ -85,13 +85,6 @@ PUT my-index-000001/_mapping ------------ // TEST[continued] -IMPORTANT: On a <>, global ordinals are discarded -after each search and rebuilt again when they're requested. This means that -`eager_global_ordinals` should not be used on frozen indices: it would -cause global ordinals to be reloaded on every search. Instead, the index should -be force-merged to a single segment before being frozen. This avoids building -global ordinals altogether (more details can be found in the next section). - ==== Avoiding global ordinal loading Usually, global ordinals do not present a large overhead in terms of their diff --git a/docs/reference/redirects.asciidoc b/docs/reference/redirects.asciidoc index 3348fe3032a5f..c4fd78701d314 100644 --- a/docs/reference/redirects.asciidoc +++ b/docs/reference/redirects.asciidoc @@ -52,6 +52,28 @@ Refer to <>. See <>. +[role="exclude",id="freeze-index-api"] +=== Freeze index API + +The freeze index API was removed in 8.0. +// tag::frozen-removal-explanation[] +Frozen indices are no longer useful due to +https://www.elastic.co/blog/significantly-decrease-your-elasticsearch-heap-memory-usage[recent +improvements in heap memory usage]. +// end::frozen-removal-explanation[] + +[role="exclude",id="ilm-freeze"] +=== Freeze {ilm-init} action + +The freeze {ilm-init} action was removed in 8.0. +include::redirects.asciidoc[tag=frozen-removal-explanation] + +[role="exclude",id="ilm-freeze-action"] +=== Freeze {ilm-init} action + +The freeze {ilm-init} action was removed in 8.0. +include::redirects.asciidoc[tag=frozen-removal-explanation] + [role="exclude",id="alias"] === Aliases @@ -1039,11 +1061,6 @@ See <>. See <>. -[role="exclude",id="ilm-freeze-action"] -==== Freeze action - -See <>. - [role="exclude",id="ilm-migrate-action"] ==== Migrate action @@ -1636,9 +1653,8 @@ See <>. === Frozen indices // tag::frozen-index-redirect[] -include::{es-repo-dir}/indices/apis/freeze.asciidoc[tag=freeze-api-dep] -For API documentation, see <> and <>. +For API documentation, see <>. // end::frozen-index-redirect[] [role="exclude",id="best_practices"] @@ -1663,16 +1679,16 @@ See the {glossary}/terms.html[Elastic glossary]. [role="exclude",id="multi-index"] === Multi-target syntax -See <>. +See <>. [float] [[hidden]] ==== Hidden data streams and indices -See <>. +See <>. [role="exclude",id="date-math-index-names"] -=== Date math support in system and index alias names +=== Date math support in system and index alias names See <>. diff --git a/docs/reference/search/search-your-data/long-running-searches.asciidoc b/docs/reference/search/search-your-data/long-running-searches.asciidoc index 3cf818b7ad286..21d48df3079ad 100644 --- a/docs/reference/search/search-your-data/long-running-searches.asciidoc +++ b/docs/reference/search/search-your-data/long-running-searches.asciidoc @@ -5,8 +5,7 @@ {es} generally allows you to quickly search across big amounts of data. There are situations where a search executes on many shards, possibly against -<> and spanning multiple -<>, for which +large data sets or multiple <>, for which results are not expected to be returned in milliseconds. When you need to execute long-running searches, synchronously waiting for its results to be returned is not ideal. Instead, Async search lets diff --git a/docs/reference/search/search-your-data/search-your-data.asciidoc b/docs/reference/search/search-your-data/search-your-data.asciidoc index 59952312e18e5..61e61fe661943 100644 --- a/docs/reference/search/search-your-data/search-your-data.asciidoc +++ b/docs/reference/search/search-your-data/search-your-data.asciidoc @@ -220,8 +220,7 @@ _synchronous_ by default. The search request waits for complete results before returning a response. However, complete results can take longer for searches across -<> or <>. +large data sets or <>. To avoid long waits, you can run an _asynchronous_, or _async_, search instead. An <> lets you retrieve partial diff --git a/docs/reference/sql/endpoints/jdbc.asciidoc b/docs/reference/sql/endpoints/jdbc.asciidoc index 7b0e74cd4951a..9e09af2368dcf 100644 --- a/docs/reference/sql/endpoints/jdbc.asciidoc +++ b/docs/reference/sql/endpoints/jdbc.asciidoc @@ -145,7 +145,7 @@ will be - typically the first in natural ascending order) for fields with multip [discrete] ==== Index -`index.include.frozen` (default `false`):: Whether to include <> in the query execution or not (default). +`index.include.frozen` (default `false`):: Whether to include frozen indices in the query execution or not (default). [discrete] ==== Additional diff --git a/docs/reference/sql/language/indices.asciidoc b/docs/reference/sql/language/indices.asciidoc index 6180f5b1c07ca..8887733325a51 100644 --- a/docs/reference/sql/language/indices.asciidoc +++ b/docs/reference/sql/language/indices.asciidoc @@ -49,7 +49,7 @@ Using `SHOW TABLES` command again: include-tagged::{sql-specs}/docs/docs.csv-spec[showTablesLikeWildcard] ---- -The pattern matches all tables that start with `emp`. +The pattern matches all tables that start with `emp`. This command supports _escaping_ as well, for example: @@ -88,7 +88,7 @@ requires the keyword `LIKE` for SQL `LIKE` pattern. [[sql-index-frozen]] === Frozen Indices -By default, {es-sql} doesn't search <>. To +By default, {es-sql} doesn't search <>. To search frozen indices, use one of the following features: dedicated configuration parameter:: @@ -108,4 +108,4 @@ include-tagged::{sql-specs}/docs/docs.csv-spec[showTablesIncludeFrozen] include-tagged::{sql-specs}/docs/docs.csv-spec[fromTableIncludeFrozen] ---- -Unless enabled, frozen indices are completely ignored; it is as if they do not exist and as such, queries ran against them are likely to fail. \ No newline at end of file +Unless enabled, frozen indices are completely ignored; it is as if they do not exist and as such, queries ran against them are likely to fail. diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.freeze.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.freeze.json deleted file mode 100644 index f7ef92dfd4266..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.freeze.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "indices.freeze":{ - "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html", - "description":"Freezes an index. A frozen index has almost no overhead on the cluster (except for maintaining its metadata in memory) and is read-only." - }, - "stability":"stable", - "visibility":"public", - "headers":{ - "accept": [ "application/json"] - }, - "url":{ - "paths":[ - { - "path":"/{index}/_freeze", - "methods":[ - "POST" - ], - "parts":{ - "index":{ - "type":"string", - "description":"The name of the index to freeze" - } - }, - "deprecated":{ - "version":"7.14.0", - "description":"Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - } - } - ] - }, - "params":{ - "timeout":{ - "type":"time", - "description":"Explicit operation timeout" - }, - "master_timeout":{ - "type":"time", - "description":"Specify timeout for connection to master" - }, - "ignore_unavailable":{ - "type":"boolean", - "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)" - }, - "allow_no_indices":{ - "type":"boolean", - "description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" - }, - "expand_wildcards":{ - "type":"enum", - "options":[ - "open", - "closed", - "hidden", - "none", - "all" - ], - "default":"closed", - "description":"Whether to expand wildcard expression to concrete indices that are open, closed or both." - }, - "wait_for_active_shards":{ - "type":"string", - "description":"Sets the number of active shards to wait for before the operation returns." - } - } - } -} diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index c295c472defc3..73b6f4f8c74f2 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -108,6 +108,11 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task -> task.skipTest("rollup/put_job/Test basic put_job", "rollup was an experimental feature, also see #41227") task.skipTest("rollup/start_job/Test start job twice", "rollup was an experimental feature, also see #41227") task.skipTest("ml/trained_model_cat_apis/Test cat trained models", "A type field was added to cat.ml_trained_models #73660, this is a backwards compatible change. Still this is a cat api, and we don't support them with rest api compatibility. (the test would be very hard to transform too)") + task.skipTest("api_key/10_basic/Test invalidate api keys with single id", "waiting for https://github.com/elastic/elasticsearch/pull/78664") + task.skipTest("indices.freeze/30_usage/Usage stats on frozen indices", "#70192 -- the freeze index API is removed from 8.0") + task.skipTest("indices.freeze/20_stats/Translog stats on frozen indices", "#70192 -- the freeze index API is removed from 8.0") + task.skipTest("indices.freeze/10_basic/Basic", "#70192 -- the freeze index API is removed from 8.0") + task.skipTest("indices.freeze/10_basic/Test index options", "#70192 -- the freeze index API is removed from 8.0") task.skipTest("ml/categorization_agg/Test categorization aggregation with poor settings", "https://github.com/elastic/elasticsearch/pull/79586") task.replaceValueInMatch("_type", "_doc") diff --git a/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java b/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java index acc98a5d26ebe..c1ee3bd1d0356 100644 --- a/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java +++ b/x-pack/plugin/frozen-indices/src/main/java/org/elasticsearch/xpack/frozen/rest/action/RestFreezeIndexAction.java @@ -29,15 +29,11 @@ public final class RestFreezeIndexAction extends BaseRestHandler { @Override public List routes() { - return List.of( - Route.builder(POST, "/{index}/_freeze").deprecated(DEPRECATION_WARNING, DEPRECATION_VERSION).build(), - Route.builder(POST, "/{index}/_unfreeze").deprecated(DEPRECATION_WARNING, DEPRECATION_VERSION).build() - ); + return List.of(Route.builder(POST, "/{index}/_unfreeze").deprecated(DEPRECATION_WARNING, DEPRECATION_VERSION).build()); } @Override protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) { - boolean freeze = request.path().endsWith("/_freeze"); FreezeRequest freezeRequest = new FreezeRequest(Strings.splitStringByCommaToArray(request.param("index"))); freezeRequest.timeout(request.paramAsTime("timeout", freezeRequest.timeout())); freezeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", freezeRequest.masterNodeTimeout())); @@ -46,7 +42,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli if (waitForActiveShards != null) { freezeRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); } - freezeRequest.setFreeze(freeze); + freezeRequest.setFreeze(false); return channel -> client.execute(FreezeIndexAction.INSTANCE, freezeRequest, new RestToXContentListener<>(channel)); } diff --git a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java index 2f27f14b142d7..0a9682139cd1e 100644 --- a/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java +++ b/x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java @@ -44,13 +44,9 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; public abstract class AbstractSearchableSnapshotsRestTestCase extends ESRestTestCase { - public static final String FROZEN_INDICES_WARNING = "Frozen indices are deprecated because they provide no benefit given " - + "improvements in heap memory utilization. They will be removed in a future release."; - private static final String WRITE_REPOSITORY_NAME = "repository"; private static final String READ_REPOSITORY_NAME = "read-repository"; private static final String SNAPSHOT_NAME = "searchable-snapshot"; @@ -179,30 +175,6 @@ public void testSearchResults() throws Exception { }); } - public void testSearchResultsWhenFrozen() throws Exception { - runSearchableSnapshotsTest((restoredIndexName, numDocs) -> { - final Request freezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_freeze"); - freezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING)); - assertOK(client().performRequest(freezeRequest)); - ensureGreen(restoredIndexName); - assertSearchResults(restoredIndexName, numDocs, Boolean.FALSE); - final Map frozenIndexSettings = indexSettings(restoredIndexName); - assertThat(Boolean.valueOf(extractValue(frozenIndexSettings, "index.frozen")), equalTo(true)); - assertThat(Boolean.valueOf(extractValue(frozenIndexSettings, "index.search.throttled")), equalTo(true)); - assertThat(Boolean.valueOf(extractValue(frozenIndexSettings, "index.blocks.write")), equalTo(true)); - - final Request unfreezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_unfreeze"); - unfreezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING)); - assertOK(client().performRequest(unfreezeRequest)); - ensureGreen(restoredIndexName); - assertSearchResults(restoredIndexName, numDocs, Boolean.FALSE); - final Map unfrozenIndexSettings = indexSettings(restoredIndexName); - assertThat(extractValue(unfrozenIndexSettings, "index.frozen"), nullValue()); - assertThat(extractValue(unfrozenIndexSettings, "index.search.throttled"), nullValue()); - assertThat(Boolean.valueOf(extractValue(frozenIndexSettings, "index.blocks.write")), equalTo(true)); - }); - } - public void testSourceOnlyRepository() throws Exception { runSearchableSnapshotsTest((indexName, numDocs) -> { for (int i = 0; i < 10; i++) { @@ -292,14 +264,6 @@ public void testClearCache() throws Exception { public void testSnapshotOfSearchableSnapshot() throws Exception { runSearchableSnapshotsTest((restoredIndexName, numDocs) -> { - final boolean frozen = randomBoolean(); - if (frozen) { - logger.info("--> freezing index [{}]", restoredIndexName); - final Request freezeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_freeze"); - freezeRequest.setOptions(expectWarnings(FROZEN_INDICES_WARNING)); - assertOK(client().performRequest(freezeRequest)); - } - if (randomBoolean()) { logger.info("--> closing index [{}]", restoredIndexName); final Request closeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_close"); @@ -347,7 +311,7 @@ public void testSnapshotOfSearchableSnapshot() throws Exception { deleteSnapshot(snapshot2Name, false); - assertSearchResults(restoredIndexName, numDocs, frozen ? Boolean.FALSE : randomFrom(Boolean.TRUE, Boolean.FALSE, null)); + assertSearchResults(restoredIndexName, numDocs, randomFrom(Boolean.TRUE, Boolean.FALSE, null)); }); } diff --git a/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle b/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle index 6837b36f427c9..fb2f48541dacb 100644 --- a/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle +++ b/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle @@ -18,6 +18,7 @@ def remoteClusterReg = testClusters.register('remote-cluster') { setting 'xpack.security.autoconfiguration.enabled', 'false' user username: "test_user", password: "x-pack-test-password" + plugin ':x-pack:qa:freeze-plugin' } def integTestClusterReg = testClusters.register('integTest') { @@ -33,6 +34,7 @@ def integTestClusterReg = testClusters.register('integTest') { setting 'xpack.security.autoconfiguration.enabled', 'false' user username: "test_user", password: "x-pack-test-password" + plugin ':x-pack:qa:freeze-plugin' } tasks.register("startRemoteCluster", DefaultTestClustersTask.class) { diff --git a/x-pack/plugin/sql/qa/server/multi-node/build.gradle b/x-pack/plugin/sql/qa/server/multi-node/build.gradle index 73a775e18f0c8..acdd38750404f 100644 --- a/x-pack/plugin/sql/qa/server/multi-node/build.gradle +++ b/x-pack/plugin/sql/qa/server/multi-node/build.gradle @@ -10,4 +10,5 @@ testClusters.matching { it.name == "integTest" }.configureEach { numberOfNodes = 2 setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' + plugin ':x-pack:qa:freeze-plugin' } diff --git a/x-pack/plugin/sql/qa/server/security/build.gradle b/x-pack/plugin/sql/qa/server/security/build.gradle index 9e3d4fe1f99a7..d7216d25d52b0 100644 --- a/x-pack/plugin/sql/qa/server/security/build.gradle +++ b/x-pack/plugin/sql/qa/server/security/build.gradle @@ -36,6 +36,7 @@ subprojects { user username: "user1", password: 'x-pack-test-password', role: "user1" user username: "user2", password: 'x-pack-test-password', role: "user2" user username: "manage_user", password: 'x-pack-test-password', role: "manage_user" + plugin ':x-pack:qa:freeze-plugin' } File testArtifactsDir = project.file("$buildDir/testArtifacts") diff --git a/x-pack/plugin/sql/qa/server/single-node/build.gradle b/x-pack/plugin/sql/qa/server/single-node/build.gradle index b66ed7ca5038b..211bf3e3d90e1 100644 --- a/x-pack/plugin/sql/qa/server/single-node/build.gradle +++ b/x-pack/plugin/sql/qa/server/single-node/build.gradle @@ -1,4 +1,6 @@ testClusters.matching { it.name == "integTest" }.configureEach { + testDistribution = 'DEFAULT' setting 'xpack.security.enabled', 'false' setting 'xpack.license.self_generated.type', 'trial' + plugin ':x-pack:qa:freeze-plugin' } diff --git a/x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/DataLoader.java b/x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/DataLoader.java index e33b1f518f811..32291f45442f1 100644 --- a/x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/DataLoader.java +++ b/x-pack/plugin/sql/qa/server/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/DataLoader.java @@ -28,8 +28,6 @@ import java.util.List; import java.util.Map; -import static org.elasticsearch.test.rest.ESRestTestCase.expectWarnings; - public class DataLoader { public static void main(String[] args) throws Exception { @@ -405,12 +403,6 @@ public static void makeAlias(RestClient client, String aliasName, String... indi protected static void freeze(RestClient client, String... indices) throws Exception { for (String index : indices) { Request freezeRequest = new Request("POST", "/" + index + "/_freeze"); - freezeRequest.setOptions( - expectWarnings( - "Frozen indices are deprecated because they provide no benefit given improvements in " - + "heap memory utilization. They will be removed in a future release." - ) - ); client.performRequest(freezeRequest); } } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/10_basic.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/10_basic.yml deleted file mode 100644 index 6d11fff4e81a7..0000000000000 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/10_basic.yml +++ /dev/null @@ -1,186 +0,0 @@ ---- -"Basic": -- skip: - features: [ "warnings" ] - -- do: - index: - index: test - id: "1" - body: { "foo": "Hello: 1" } -- do: - index: - index: test - id: "2" - body: { "foo": "Hello: 2" } - -- do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.freeze: - index: test - -- do: - warnings: - - "[ignore_throttled] parameter is deprecated because frozen indices have been deprecated. Consider cold or frozen tiers in place of frozen indices." - - "Searching frozen indices [test] is deprecated. Consider cold or frozen tiers in place of frozen indices. The frozen feature will be removed in a feature release." - search: - rest_total_hits_as_int: true - index: test - ignore_throttled: false - body: - query: - match: - foo: hello - -- match: {hits.total: 2} - -# unfreeze -- do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.unfreeze: - index: test - -- do: - search: - rest_total_hits_as_int: true - index: _all - body: - query: - match: - foo: hello - -- match: {hits.total: 2} - -- do: - index: - index: test-01 - id: "1" - body: { "foo": "Hello: 01" } - - -- do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.freeze: - index: test* - -- do: - warnings: - - "[ignore_throttled] parameter is deprecated because frozen indices have been deprecated. Consider cold or frozen tiers in place of frozen indices." - - "Searching frozen indices [test,test-01] is deprecated. Consider cold or frozen tiers in place of frozen indices. The frozen feature will be removed in a feature release." - search: - rest_total_hits_as_int: true - index: _all - ignore_throttled: false - body: - query: - match: - foo: hello - -- match: {hits.total: 3} - -- do: - search: - rest_total_hits_as_int: true - index: _all - body: - query: - match: - foo: hello - -- match: {hits.total: 0} - ---- -"Test index options": -- skip: - features: ["allowed_warnings", "warnings"] - -- do: - index: - index: test - id: "1" - body: { "foo": "Hello: 1" } - -- do: - index: - index: test-close - id: "1" - body: { "foo": "Hello: 1" } - -- do: - indices.close: - index: test-close - allowed_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" - -- do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.freeze: - index: test*,not_available - ignore_unavailable: true - -- do: - search: - rest_total_hits_as_int: true - index: _all - body: - query: - match: - foo: hello - -- match: {hits.total: 0} - -- do: - warnings: - - "[ignore_throttled] parameter is deprecated because frozen indices have been deprecated. Consider cold or frozen tiers in place of frozen indices." - - "Searching frozen indices [test] is deprecated. Consider cold or frozen tiers in place of frozen indices. The frozen feature will be removed in a feature release." - search: - rest_total_hits_as_int: true - index: _all - ignore_throttled: false - body: - query: - match: - foo: hello - -- match: {hits.total: 1} - ---- -"Cannot freeze write index for data stream": - - skip: - version: " - 7.9.99" - reason: "enable in 7.9+ when backported" - features: allowed_warnings - - - do: - allowed_warnings: - - "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation" - indices.put_index_template: - name: my-template1 - body: - index_patterns: [simple-data-stream1] - template: - mappings: - properties: - '@timestamp': - type: date - data_stream: {} - - - do: - indices.create_data_stream: - name: simple-data-stream1 - - is_true: acknowledged - - - do: - catch: bad_request - indices.freeze: - index: ".ds-simple-data-stream1-*000001" - - - do: - indices.delete_data_stream: - name: simple-data-stream1 - - is_true: acknowledged - diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/20_stats.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/20_stats.yml deleted file mode 100644 index 0ce2b8c22fd61..0000000000000 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/20_stats.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -setup: - - do: - indices.create: - index: test - - do: - cluster.health: - wait_for_no_initializing_shards: true - ---- -"Translog stats on frozen indices": - - skip: - features: warnings - version: " - 7.3.99" - reason: "start ignoring translog retention policy with soft-deletes enabled in 7.4" - - - do: - index: - index: test - id: 1 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 2 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 3 - body: { "foo": "bar" } - - - do: - indices.stats: - metric: [ translog ] - - match: { indices.test.primaries.translog.operations: 3 } - - match: { indices.test.primaries.translog.uncommitted_operations: 3 } - - # freeze index - - do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.freeze: - index: test - - is_true: acknowledged - - - do: - indices.stats: - metric: [ translog ] - - match: { indices.test.primaries.translog.operations: 0 } - - match: { indices.test.primaries.translog.uncommitted_operations: 0 } - - # unfreeze index - - do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.unfreeze: - index: test - - is_true: acknowledged - - - do: - indices.stats: - metric: [ translog ] - - match: { indices.test.primaries.translog.operations: 0 } - - match: { indices.test.primaries.translog.uncommitted_operations: 0 } diff --git a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/30_usage.yml b/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/30_usage.yml deleted file mode 100644 index f874cda55ac95..0000000000000 --- a/x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/indices.freeze/30_usage.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -setup: - - do: - indices.create: - index: test - - do: - cluster.health: - wait_for_no_initializing_shards: true - ---- -"Usage stats on frozen indices": - - skip: - features: [ "warnings" ] - version: " - 7.3.99" - reason: "frozen indices have usage stats starting in version 7.4" - - - do: - index: - index: test - id: 1 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 2 - body: { "foo": "bar" } - - - do: - index: - index: test - id: 3 - body: { "foo": "bar" } - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 0 } - - # freeze index - - do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.freeze: - index: test - - is_true: acknowledged - - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 1 } - - # unfreeze index - - do: - warnings: - - "Frozen indices are deprecated because they provide no benefit given improvements in heap memory utilization. They will be removed in a future release." - indices.unfreeze: - index: test - - is_true: acknowledged - - - do: {xpack.usage: {}} - - match: { frozen_indices.available: true } - - match: { frozen_indices.enabled: true } - - match: { frozen_indices.indices_count: 0 } diff --git a/x-pack/qa/freeze-plugin/build.gradle b/x-pack/qa/freeze-plugin/build.gradle new file mode 100644 index 0000000000000..c9642b89922ef --- /dev/null +++ b/x-pack/qa/freeze-plugin/build.gradle @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + + +apply plugin: 'elasticsearch.internal-es-plugin' + + +esplugin { + name = 'freeze-plugin' + description = 'Provides freeze-index endpoint for testing purposes only' + classname = 'org.elasticsearch.plugin.freeze.FreezeIndexPlugin' + extendedPlugins = ['x-pack-core'] +} + +dependencies { + compileOnly project(":server") + compileOnly project(path: xpackModule('core')) +} + +//this plugin is only for testing purposes -- there are no unit tests +tasks.named("testingConventions").configure { enabled = false } diff --git a/x-pack/qa/freeze-plugin/src/main/java/org/elasticsearch/plugin/freeze/FreezeIndexPlugin.java b/x-pack/qa/freeze-plugin/src/main/java/org/elasticsearch/plugin/freeze/FreezeIndexPlugin.java new file mode 100644 index 0000000000000..0de041ab00cd5 --- /dev/null +++ b/x-pack/qa/freeze-plugin/src/main/java/org/elasticsearch/plugin/freeze/FreezeIndexPlugin.java @@ -0,0 +1,85 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.plugin.freeze; + +import org.elasticsearch.action.support.ActiveShardCount; +import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; +import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.ClusterSettings; +import org.elasticsearch.common.settings.IndexScopedSettings; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.settings.SettingsFilter; +import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.protocol.xpack.frozen.FreezeRequest; +import org.elasticsearch.rest.BaseRestHandler; +import org.elasticsearch.rest.RestController; +import org.elasticsearch.rest.RestHandler; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.action.RestToXContentListener; +import org.elasticsearch.xpack.core.frozen.action.FreezeIndexAction; + +import java.io.IOException; +import java.util.List; +import java.util.function.Supplier; + +import static org.elasticsearch.rest.RestRequest.Method.POST; + +/** + * Restores the REST endpoint for freezing indices so that the JDBC tests can still freeze indices + * for testing purposes until frozen indices are no longer supported. + */ +public class FreezeIndexPlugin extends Plugin implements ActionPlugin { + + @Override + public List getRestHandlers( + Settings settings, + RestController restController, + ClusterSettings clusterSettings, + IndexScopedSettings indexScopedSettings, + SettingsFilter settingsFilter, + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier nodesInCluster + ) { + return List.of(new FreezeIndexRestEndpoint()); + } + + /** + * Used by the {@link FreezeIndexPlugin} above. + */ + static class FreezeIndexRestEndpoint extends BaseRestHandler { + @Override + public String getName() { + return "freeze-for-testing-only"; + } + + @Override + public List routes() { + return List.of(new Route(POST, "/{index}/_freeze")); + } + + @Override + protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { + boolean freeze = request.path().endsWith("/_freeze"); + FreezeRequest freezeRequest = new FreezeRequest(Strings.splitStringByCommaToArray(request.param("index"))); + freezeRequest.timeout(request.paramAsTime("timeout", freezeRequest.timeout())); + freezeRequest.masterNodeTimeout(request.paramAsTime("master_timeout", freezeRequest.masterNodeTimeout())); + freezeRequest.indicesOptions(IndicesOptions.fromRequest(request, freezeRequest.indicesOptions())); + String waitForActiveShards = request.param("wait_for_active_shards"); + if (waitForActiveShards != null) { + freezeRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards)); + } + freezeRequest.setFreeze(freeze); + return channel -> client.execute(FreezeIndexAction.INSTANCE, freezeRequest, new RestToXContentListener<>(channel)); + } + } + +} diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 3374ea12b3aee..fc161c2b4c8c7 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -19,6 +19,12 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.support.XContentMapValues; +import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.rest.action.search.RestSearchAction; +import org.elasticsearch.test.StreamsUtils; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase; import org.elasticsearch.xcontent.DeprecationHandler; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.ObjectPath; @@ -26,13 +32,6 @@ import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; -import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.search.RestSearchAction; -import org.elasticsearch.test.StreamsUtils; -import org.elasticsearch.test.rest.ESRestTestCase; -import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase; import org.elasticsearch.xpack.core.slm.SnapshotLifecyclePolicy; import org.elasticsearch.xpack.core.slm.SnapshotLifecycleStats; import org.hamcrest.Matcher; @@ -703,61 +702,6 @@ private void waitForRollUpJob(final String rollupJob, final Matcher expectedS return null; } - public void testFrozenIndexAfterRestarted() throws Exception { - final String index = "test_frozen_index"; - if (isRunningAgainstOldCluster()) { - Settings.Builder settings = Settings.builder(); - if (minimumNodeVersion().before(Version.V_8_0_0) && randomBoolean()) { - settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); - } - String mappings = randomBoolean() ? "\"_source\": { \"enabled\": false}" : null; - createIndex(index, settings.build(), mappings); - ensureGreen(index); - int numDocs = randomIntBetween(10, 500); - for (int i = 0; i < numDocs; i++) { - int id = randomIntBetween(0, 100); - final Request indexRequest = new Request("POST", "/" + index + "/" + "_doc/" + id); - indexRequest.setJsonEntity(Strings.toString(JsonXContent.contentBuilder().startObject().field("f", "v").endObject())); - assertOK(client().performRequest(indexRequest)); - if (rarely()) { - flush(index, randomBoolean()); - } - } - } else { - ensureGreen(index); - final int totalHits = (int) XContentMapValues.extractValue("hits.total.value", - entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")))); - Request freezeRequest = new Request("POST", index + "/_freeze"); - freezeRequest.setOptions( - expectWarnings( - "Frozen indices are deprecated because they provide no benefit given " - + "improvements in heap memory utilization. They will be removed in a future release." - ) - ); - assertOK(client().performRequest(freezeRequest)); - ensureGreen(index); - assertNoFileBasedRecovery(index, n -> true); - final Request request = new Request("GET", "/" + index + "/_search"); - request.setOptions(expectWarnings("[ignore_throttled] parameter is deprecated because frozen " + - "indices have been deprecated. Consider cold or frozen tiers in place of frozen indices.", - "Searching frozen indices [" + index + "] is deprecated. " + - "Consider cold or frozen tiers in place of frozen indices. The frozen feature will be removed in a feature release.")); - request.addParameter("ignore_throttled", "false"); - assertThat(XContentMapValues.extractValue("hits.total.value", entityAsMap(client().performRequest(request))), - equalTo(totalHits)); - final Request unfreezeRequest = new Request("POST", index + "/_unfreeze"); - unfreezeRequest.setOptions( - expectWarnings( - "Frozen indices are deprecated because they provide no benefit given " - + "improvements in heap memory utilization. They will be removed in a future release." - ) - ); - assertOK(client().performRequest(unfreezeRequest)); - ensureGreen(index); - assertNoFileBasedRecovery(index, n -> true); - } - } - @SuppressWarnings("unchecked") public void testDataStreams() throws Exception { assumeTrue("no data streams in versions before " + Version.V_7_9_0, getOldClusterVersion().onOrAfter(Version.V_7_9_0));