Browse Source

Deprecate delaying state recovery for master nodes (#53646)

It is useful to be able to delay state recovery until enough data nodes have
joined the cluster, since this gives the shard allocator a decent opportunity
to re-use as much existing data as possible. However we also have the option to
delay state recovery until a certain number of master-eligible nodes have
joined, and this is unnecessary: we require a majority of master-eligible nodes
for state recovery, and there is no advantage in waiting for more.

This commit deprecates the unnecessary settings in preparation for their
removal.

Relates #51806
Tianlun Li 5 years ago
parent
commit
fe5092ae24

+ 8 - 4
docs/reference/modules/gateway.asciidoc

@@ -10,12 +10,14 @@ recover the cluster state and the cluster's data:
 
 `gateway.expected_nodes`::
 
+    deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.expected_data_nodes` instead.]
     The number of (data or master) nodes that are expected to be in the cluster.
     Recovery of local shards will start as soon as the expected number of
     nodes have joined the cluster. Defaults to `0`
 
 `gateway.expected_master_nodes`::
 
+    deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.expected_data_nodes` instead.]
     The number of master nodes that are expected to be in the cluster.
     Recovery of local shards will start as soon as the expected number of
     master nodes have joined the cluster. Defaults to `0`
@@ -37,10 +39,12 @@ as long as the following conditions are met:
 
 `gateway.recover_after_nodes`::
 
+    deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.recover_after_data_nodes` instead.]
     Recover as long as this many data or master nodes have joined the cluster.
 
 `gateway.recover_after_master_nodes`::
 
+    deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.recover_after_data_nodes` instead.]
     Recover as long as this many master nodes have joined the cluster.
 
 `gateway.recover_after_data_nodes`::
@@ -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.

+ 4 - 4
server/src/main/java/org/elasticsearch/gateway/GatewayService.java

@@ -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);

+ 18 - 9
server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java

@@ -21,6 +21,7 @@ package org.elasticsearch.gateway;
 
 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;
@@ -40,24 +41,32 @@ public class GatewayServiceTests extends ESTestCase {
         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 });
+    }
+
 }