Skip to content
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

Deprecated support for delaying state recovery pending master nodes #53646

Merged
merged 3 commits into from
Mar 18, 2020
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
12 changes: 8 additions & 4 deletions docs/reference/modules/gateway.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ recover the cluster state and the cluster's data:
The number of (data or master) nodes that are expected to be in the cluster.
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved
Recovery of local shards will start as soon as the expected number of
nodes have joined the cluster. Defaults to `0`
Deprecated and will be removed in 8.0
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved

`gateway.expected_master_nodes`::

The number of master nodes that are expected to be in the cluster.
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved
Recovery of local shards will start as soon as the expected number of
master nodes have joined the cluster. Defaults to `0`
Deprecated and will be removed in 8.0
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved

`gateway.expected_data_nodes`::

Expand All @@ -38,10 +40,12 @@ as long as the following conditions are met:
`gateway.recover_after_nodes`::

Recover as long as this many data or master nodes have joined the cluster.
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved
Deprecated and will be removed in 8.0
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved

`gateway.recover_after_master_nodes`::

Recover as long as this many master nodes have joined the cluster.
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved
Deprecated and will be removed in 8.0
ShawnLi1014 marked this conversation as resolved.
Show resolved Hide resolved

`gateway.recover_after_data_nodes`::

Expand All @@ -53,8 +57,8 @@ NOTE: These settings only take effect on a full cluster restart.
=== Dangling indices

When a node joins the cluster, any shards stored in its local data
directory which do not already exist in the cluster will be imported into the
cluster. This functionality is intended as a best effort to help users who
lose all master nodes. If a new master node is started which is unaware of
the other indices in the cluster, adding the old nodes will cause the old
directory which do not already exist in the cluster will be imported into the
cluster. This functionality is intended as a best effort to help users who
lose all master nodes. If a new master node is started which is unaware of
the other indices in the cluster, adding the old nodes will cause the old
indices to be imported, instead of being deleted.
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public class GatewayService extends AbstractLifecycleComponent implements Cluste
private static final Logger logger = LogManager.getLogger(GatewayService.class);

public static final Setting<Integer> EXPECTED_NODES_SETTING =
Setting.intSetting("gateway.expected_nodes", -1, -1, Property.NodeScope);
Setting.intSetting("gateway.expected_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
public static final Setting<Integer> EXPECTED_DATA_NODES_SETTING =
Setting.intSetting("gateway.expected_data_nodes", -1, -1, Property.NodeScope);
public static final Setting<Integer> EXPECTED_MASTER_NODES_SETTING =
Setting.intSetting("gateway.expected_master_nodes", -1, -1, Property.NodeScope);
Setting.intSetting("gateway.expected_master_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
public static final Setting<TimeValue> RECOVER_AFTER_TIME_SETTING =
Setting.positiveTimeSetting("gateway.recover_after_time", TimeValue.timeValueMillis(0), Property.NodeScope);
public static final Setting<Integer> RECOVER_AFTER_NODES_SETTING =
Setting.intSetting("gateway.recover_after_nodes", -1, -1, Property.NodeScope);
Setting.intSetting("gateway.recover_after_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
public static final Setting<Integer> RECOVER_AFTER_DATA_NODES_SETTING =
Setting.intSetting("gateway.recover_after_data_nodes", -1, -1, Property.NodeScope);
public static final Setting<Integer> RECOVER_AFTER_MASTER_NODES_SETTING =
Setting.intSetting("gateway.recover_after_master_nodes", 0, 0, Property.NodeScope);
Setting.intSetting("gateway.recover_after_master_nodes", 0, 0, Property.NodeScope, Property.Deprecated);

public static final ClusterBlock STATE_NOT_RECOVERED_BLOCK = new ClusterBlock(1, "state not recovered / initialized", true, true,
false, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESTestCase;
Expand All @@ -40,24 +41,32 @@ public void testDefaultRecoverAfterTime() {
GatewayService service = createService(Settings.builder());
assertNull(service.recoverAfterTime());

// ensure default is set when setting expected_nodes
service = createService(Settings.builder().put("gateway.expected_nodes", 1));
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));

// ensure default is set when setting expected_data_nodes
service = createService(Settings.builder().put("gateway.expected_data_nodes", 1));
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));

// ensure default is set when setting expected_master_nodes
service = createService(Settings.builder().put("gateway.expected_master_nodes", 1));
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));

// ensure settings override default
final TimeValue timeValue = TimeValue.timeValueHours(3);
// ensure default is set when setting expected_nodes
service = createService(Settings.builder().put("gateway.expected_nodes", 1).put("gateway.recover_after_time",
service = createService(Settings.builder().put("gateway.recover_after_time",
timeValue.toString()));
assertThat(service.recoverAfterTime().millis(), Matchers.equalTo(timeValue.millis()));
}

public void testDeprecatedSettings() {
GatewayService service = createService(Settings.builder());

service = createService(Settings.builder().put("gateway.expected_nodes", 1));
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.EXPECTED_NODES_SETTING });

service = createService(Settings.builder().put("gateway.expected_master_nodes", 1));
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.EXPECTED_MASTER_NODES_SETTING });

service = createService(Settings.builder().put("gateway.recover_after_nodes", 1));
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.RECOVER_AFTER_NODES_SETTING });

service = createService(Settings.builder().put("gateway.recover_after_master_nodes", 1));
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING });
}

}