-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Allow copying source settings on resize operation #30255
Changes from 4 commits
d48f16c
a95c60b
00ed7cc
796f011
c7571ec
71082aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,8 +177,13 @@ POST my_source_index/_split/my_target_index | |
|
||
NOTE: Mappings may not be specified in the `_split` request. | ||
|
||
NOTE: By default, with the exception of `index.analysis`, `index.similarity`, and `index.sort` settings, index settings on the source | ||
index are not copied during a shrink operation. | ||
NOTE: By default, with the exception of `index.analysis`, `index.similarity`, | ||
and `index.sort` settings, index settings on the source index are not copied | ||
during a split operation. With the exception of non-copyable settings, settings | ||
from the source index can be copied to the target index by adding the URL | ||
parameter `copy_settings=true` to the request. | ||
|
||
deprecated[7.0.0, `copy_settings` will default to `true` in 8.x and will be removed in 9.0.0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
|
||
[float] | ||
=== Monitoring the split process | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,8 +61,23 @@ backwards compatibility. Backwards support for the `suggest` metric was | |
deprecated in 6.3.0 and now removed in 7.0.0. | ||
|
||
[[remove-field-caps-body]] | ||
==== In the fields capabilities API, `fields` can no longer be provided in the request body. | ||
|
||
In the past, `fields` could be provided either as a parameter, or as part of the request | ||
body. Specifying `fields` in the request body as opposed to a parameter was deprecated | ||
in 6.4.0, and is now unsupported in 7.0.0. | ||
|
||
==== Copying source settings during shrink/split operations | ||
|
||
In prior versions of Elasticsearch, resize operations (shrink/split) would only | ||
copy `index.analysis`, `index.similarity`, and `index.sort` settings from the | ||
source index. Elasticsearch 7.0.0 introduces a request parameter `copy_settings` | ||
which will copy all index settings from the source except for non-copyable index | ||
settings. This parameter defaults to `false` in 7.x, is immediately deprecated | ||
in 7.0.0, will only be able to be set to `true` in 8.x, and will be removed in | ||
9.0.0. Note than when this parameter is used it means that all copyable settings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
will be copied; this includes the index blocks that must be put in place for a | ||
resize operation, and any allocation settings put in place in preparation for | ||
executing the resize operation. If you use this parameter, you will either have | ||
to follow up the operation with a request to adjust to the desired settings on | ||
the target index, or send the desired value of these settings with the resize | ||
operation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
"Copy settings during shrink index": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: copy_settings did not exist prior to 7.0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
features: "warnings" | ||
|
||
- do: | ||
cluster.state: {} | ||
|
||
# get master node id | ||
- set: { master_node: master } | ||
|
||
- do: | ||
indices.create: | ||
index: source | ||
wait_for_active_shards: 1 | ||
body: | ||
settings: | ||
# ensure everything is allocated on the master node | ||
index.routing.allocation.include._id: $master | ||
index.number_of_replicas: 0 | ||
index.merge.scheduler.max_merge_count: 4 | ||
|
||
# make it read-only | ||
- do: | ||
indices.put_settings: | ||
index: source | ||
body: | ||
index.blocks.write: true | ||
index.number_of_replicas: 0 | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
index: source | ||
|
||
# now we do a actual shrink and copy settings | ||
- do: | ||
indices.shrink: | ||
index: "source" | ||
target: "copy-settings-target" | ||
wait_for_active_shards: 1 | ||
master_timeout: 10s | ||
copy_settings: true | ||
body: | ||
settings: | ||
index.number_of_replicas: 0 | ||
index.merge.scheduler.max_thread_count: 2 | ||
warnings: | ||
- "parameter [copy_settings] is deprecated but was [true]" | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
|
||
- do: | ||
indices.get_settings: | ||
index: "copy-settings-target" | ||
|
||
# settings should be copied | ||
- match: { copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" } | ||
- match: { copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" } | ||
- match: { copy-settings-target.settings.index.blocks.write: "true" } | ||
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master } | ||
|
||
# now we do a actual shrink and do not copy settings | ||
- do: | ||
indices.shrink: | ||
index: "source" | ||
target: "no-copy-settings-target" | ||
wait_for_active_shards: 1 | ||
master_timeout: 10s | ||
copy_settings: false | ||
body: | ||
settings: | ||
index.number_of_replicas: 0 | ||
index.merge.scheduler.max_thread_count: 2 | ||
warnings: | ||
- "parameter [copy_settings] is deprecated but was [false]" | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
|
||
- do: | ||
indices.get_settings: | ||
index: "no-copy-settings-target" | ||
|
||
# only the request setting should be copied | ||
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count | ||
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" } | ||
- is_false: no-copy-settings-target.settings.index.blocks.write | ||
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
"Copy settings during split index": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: copy_settings did not exist prior to 7.0.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
features: "warnings" | ||
|
||
- do: | ||
cluster.state: {} | ||
|
||
# get master node id | ||
- set: { master_node: master } | ||
|
||
- do: | ||
indices.create: | ||
index: source | ||
wait_for_active_shards: 1 | ||
body: | ||
settings: | ||
# ensure everything is allocated on the master node | ||
index.routing.allocation.include._id: $master | ||
index.number_of_replicas: 0 | ||
index.number_of_shards: 1 | ||
index.number_of_routing_shards: 4 | ||
index.merge.scheduler.max_merge_count: 4 | ||
|
||
# make it read-only | ||
- do: | ||
indices.put_settings: | ||
index: source | ||
body: | ||
index.blocks.write: true | ||
index.number_of_replicas: 0 | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
index: source | ||
|
||
# now we do a actual split and copy settings | ||
- do: | ||
indices.split: | ||
index: "source" | ||
target: "copy-settings-target" | ||
wait_for_active_shards: 1 | ||
master_timeout: 10s | ||
copy_settings: true | ||
body: | ||
settings: | ||
index.number_of_replicas: 0 | ||
index.number_of_shards: 2 | ||
index.merge.scheduler.max_thread_count: 2 | ||
warnings: | ||
- "parameter [copy_settings] is deprecated but was [true]" | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
|
||
- do: | ||
indices.get_settings: | ||
index: "copy-settings-target" | ||
|
||
# settings should be copied | ||
- match: { copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" } | ||
- match: { copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" } | ||
- match: { copy-settings-target.settings.index.blocks.write: "true" } | ||
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master } | ||
|
||
# now we do a actual shrink and do not copy settings | ||
- do: | ||
indices.split: | ||
index: "source" | ||
target: "no-copy-settings-target" | ||
wait_for_active_shards: 1 | ||
master_timeout: 10s | ||
copy_settings: false | ||
body: | ||
settings: | ||
index.number_of_replicas: 0 | ||
index.number_of_shards: 2 | ||
index.merge.scheduler.max_thread_count: 2 | ||
warnings: | ||
- "parameter [copy_settings] is deprecated but was [false]" | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
|
||
- do: | ||
indices.get_settings: | ||
index: "no-copy-settings-target" | ||
|
||
# only the request setting should be copied | ||
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count | ||
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" } | ||
- is_false: no-copy-settings-target.settings.index.blocks.write | ||
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
package org.elasticsearch.action.admin.indices.shrink; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.IndicesRequest; | ||
import org.elasticsearch.action.admin.indices.alias.Alias; | ||
|
@@ -55,6 +56,7 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements | |
private CreateIndexRequest targetIndexRequest; | ||
private String sourceIndex; | ||
private ResizeType type = ResizeType.SHRINK; | ||
private boolean copySettings = false; | ||
|
||
ResizeRequest() {} | ||
|
||
|
@@ -96,6 +98,11 @@ public void readFrom(StreamInput in) throws IOException { | |
} else { | ||
type = ResizeType.SHRINK; // BWC this used to be shrink only | ||
} | ||
if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
copySettings = in.readBoolean(); | ||
} else { | ||
copySettings = false; | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -106,6 +113,9 @@ public void writeTo(StreamOutput out) throws IOException { | |
if (out.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) { | ||
out.writeEnum(type); | ||
} | ||
if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be adjusted after backporting. |
||
out.writeBoolean(copySettings); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -177,6 +187,14 @@ public ResizeType getResizeType() { | |
return type; | ||
} | ||
|
||
public void setCopySettings(final boolean copySettings) { | ||
this.copySettings = copySettings; | ||
} | ||
|
||
public boolean getCopySettings() { | ||
return copySettings; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be adjusted after backporting.