Skip to content

Commit fe5092a

Browse files
authored
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
1 parent f9cbc76 commit fe5092a

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

docs/reference/modules/gateway.asciidoc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ recover the cluster state and the cluster's data:
1010

1111
`gateway.expected_nodes`::
1212

13+
deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.expected_data_nodes` instead.]
1314
The number of (data or master) nodes that are expected to be in the cluster.
1415
Recovery of local shards will start as soon as the expected number of
1516
nodes have joined the cluster. Defaults to `0`
1617

1718
`gateway.expected_master_nodes`::
1819

20+
deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.expected_data_nodes` instead.]
1921
The number of master nodes that are expected to be in the cluster.
2022
Recovery of local shards will start as soon as the expected number of
2123
master nodes have joined the cluster. Defaults to `0`
@@ -37,10 +39,12 @@ as long as the following conditions are met:
3739

3840
`gateway.recover_after_nodes`::
3941

42+
deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.recover_after_data_nodes` instead.]
4043
Recover as long as this many data or master nodes have joined the cluster.
4144

4245
`gateway.recover_after_master_nodes`::
4346

47+
deprecated:[7.7.0, This setting will be removed in 8.0. You should use `gateway.recover_after_data_nodes` instead.]
4448
Recover as long as this many master nodes have joined the cluster.
4549

4650
`gateway.recover_after_data_nodes`::
@@ -53,8 +57,8 @@ NOTE: These settings only take effect on a full cluster restart.
5357
=== Dangling indices
5458

5559
When a node joins the cluster, any shards stored in its local data
56-
directory which do not already exist in the cluster will be imported into the
57-
cluster. This functionality is intended as a best effort to help users who
58-
lose all master nodes. If a new master node is started which is unaware of
59-
the other indices in the cluster, adding the old nodes will cause the old
60+
directory which do not already exist in the cluster will be imported into the
61+
cluster. This functionality is intended as a best effort to help users who
62+
lose all master nodes. If a new master node is started which is unaware of
63+
the other indices in the cluster, adding the old nodes will cause the old
6064
indices to be imported, instead of being deleted.

server/src/main/java/org/elasticsearch/gateway/GatewayService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ public class GatewayService extends AbstractLifecycleComponent implements Cluste
5151
private static final Logger logger = LogManager.getLogger(GatewayService.class);
5252

5353
public static final Setting<Integer> EXPECTED_NODES_SETTING =
54-
Setting.intSetting("gateway.expected_nodes", -1, -1, Property.NodeScope);
54+
Setting.intSetting("gateway.expected_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
5555
public static final Setting<Integer> EXPECTED_DATA_NODES_SETTING =
5656
Setting.intSetting("gateway.expected_data_nodes", -1, -1, Property.NodeScope);
5757
public static final Setting<Integer> EXPECTED_MASTER_NODES_SETTING =
58-
Setting.intSetting("gateway.expected_master_nodes", -1, -1, Property.NodeScope);
58+
Setting.intSetting("gateway.expected_master_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
5959
public static final Setting<TimeValue> RECOVER_AFTER_TIME_SETTING =
6060
Setting.positiveTimeSetting("gateway.recover_after_time", TimeValue.timeValueMillis(0), Property.NodeScope);
6161
public static final Setting<Integer> RECOVER_AFTER_NODES_SETTING =
62-
Setting.intSetting("gateway.recover_after_nodes", -1, -1, Property.NodeScope);
62+
Setting.intSetting("gateway.recover_after_nodes", -1, -1, Property.NodeScope, Property.Deprecated);
6363
public static final Setting<Integer> RECOVER_AFTER_DATA_NODES_SETTING =
6464
Setting.intSetting("gateway.recover_after_data_nodes", -1, -1, Property.NodeScope);
6565
public static final Setting<Integer> RECOVER_AFTER_MASTER_NODES_SETTING =
66-
Setting.intSetting("gateway.recover_after_master_nodes", 0, 0, Property.NodeScope);
66+
Setting.intSetting("gateway.recover_after_master_nodes", 0, 0, Property.NodeScope, Property.Deprecated);
6767

6868
public static final ClusterBlock STATE_NOT_RECOVERED_BLOCK = new ClusterBlock(1, "state not recovered / initialized", true, true,
6969
false, RestStatus.SERVICE_UNAVAILABLE, ClusterBlockLevel.ALL);

server/src/test/java/org/elasticsearch/gateway/GatewayServiceTests.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.cluster.service.ClusterService;
2323
import org.elasticsearch.common.settings.ClusterSettings;
24+
import org.elasticsearch.common.settings.Setting;
2425
import org.elasticsearch.common.settings.Settings;
2526
import org.elasticsearch.common.unit.TimeValue;
2627
import org.elasticsearch.test.ESTestCase;
@@ -40,24 +41,32 @@ public void testDefaultRecoverAfterTime() {
4041
GatewayService service = createService(Settings.builder());
4142
assertNull(service.recoverAfterTime());
4243

43-
// ensure default is set when setting expected_nodes
44-
service = createService(Settings.builder().put("gateway.expected_nodes", 1));
45-
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));
46-
4744
// ensure default is set when setting expected_data_nodes
4845
service = createService(Settings.builder().put("gateway.expected_data_nodes", 1));
4946
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));
5047

51-
// ensure default is set when setting expected_master_nodes
52-
service = createService(Settings.builder().put("gateway.expected_master_nodes", 1));
53-
assertThat(service.recoverAfterTime(), Matchers.equalTo(GatewayService.DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET));
54-
5548
// ensure settings override default
5649
final TimeValue timeValue = TimeValue.timeValueHours(3);
5750
// ensure default is set when setting expected_nodes
58-
service = createService(Settings.builder().put("gateway.expected_nodes", 1).put("gateway.recover_after_time",
51+
service = createService(Settings.builder().put("gateway.recover_after_time",
5952
timeValue.toString()));
6053
assertThat(service.recoverAfterTime().millis(), Matchers.equalTo(timeValue.millis()));
6154
}
6255

56+
public void testDeprecatedSettings() {
57+
GatewayService service = createService(Settings.builder());
58+
59+
service = createService(Settings.builder().put("gateway.expected_nodes", 1));
60+
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.EXPECTED_NODES_SETTING });
61+
62+
service = createService(Settings.builder().put("gateway.expected_master_nodes", 1));
63+
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.EXPECTED_MASTER_NODES_SETTING });
64+
65+
service = createService(Settings.builder().put("gateway.recover_after_nodes", 1));
66+
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.RECOVER_AFTER_NODES_SETTING });
67+
68+
service = createService(Settings.builder().put("gateway.recover_after_master_nodes", 1));
69+
assertSettingDeprecationsAndWarnings(new Setting<?>[] {GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING });
70+
}
71+
6372
}

0 commit comments

Comments
 (0)