Skip to content

Commit 4db094c

Browse files
authored
Remove dangling index auto import functionality (#59698)
Closes #48366. Remove all traces of automatically importing dangling indices. This functionality is deprecated from 7.9.0.
1 parent aa3ddfe commit 4db094c

File tree

7 files changed

+72
-639
lines changed

7 files changed

+72
-639
lines changed

docs/reference/modules/gateway.asciidoc

+9-26
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,12 @@ NOTE: These settings only take effect on a full cluster restart.
5656
[[dangling-indices]]
5757
==== Dangling indices
5858

59-
When a node joins the cluster, if it finds any shards stored in its local data
60-
directory that do not already exist in the cluster, it will consider those
61-
shards to be "dangling". Importing dangling indices
62-
into the cluster using `gateway.auto_import_dangling_indices` is not safe.
63-
Instead, use the <<dangling-indices-api,Dangling indices API>>. Neither
64-
mechanism provides any guarantees as to whether the imported data truly
65-
represents the latest state of the data when the index was still part of
66-
the cluster.
67-
68-
`gateway.auto_import_dangling_indices`::
69-
70-
deprecated:[7.9.0, This setting will be removed in 8.0. You should use the dedicated dangling indices API instead.]
71-
Whether to automatically import dangling indices into the cluster
72-
state, provided no indices already exist with the same name. Defaults
73-
to `false`.
74-
75-
WARNING: The auto-import functionality was intended as a best effort to help users
76-
who lose all master nodes. For example, if a new master node were to be
77-
started which was unaware of the other indices in the cluster, adding the
78-
old nodes would cause the old indices to be imported, instead of being
79-
deleted. However there are several issues with automatic importing, and
80-
its use is strongly discouraged in favour of the
81-
<<dangling-indices-api,dedicated API>.
82-
83-
WARNING: Losing all master nodes is a situation that should be avoided at
84-
all costs, as it puts your cluster's metadata and data at risk.
59+
When a node joins the cluster, if it finds any shards stored in its local
60+
data directory that do not already exist in the cluster, it will consider
61+
those shards to belong to a "dangling" index. You can list, import or
62+
delete dangling indices using the <<dangling-indices-api,Dangling indices
63+
API>>.
64+
65+
NOTE: The API cannot offer any guarantees as to whether the imported data
66+
truly represents the latest state of the data when the index was still part
67+
of the cluster.

qa/smoke-test-http/src/test/java/org/elasticsearch/http/DanglingIndicesRestIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.util.concurrent.atomic.AtomicReference;
4040

4141
import static org.elasticsearch.cluster.metadata.IndexGraveyard.SETTING_MAX_TOMBSTONES;
42-
import static org.elasticsearch.gateway.DanglingIndicesState.AUTO_IMPORT_DANGLING_INDICES_SETTING;
4342
import static org.elasticsearch.indices.IndicesService.WRITE_DANGLING_INDICES_INFO_SETTING;
4443
import static org.elasticsearch.rest.RestStatus.ACCEPTED;
4544
import static org.elasticsearch.rest.RestStatus.OK;
@@ -70,7 +69,6 @@ private Settings buildSettings(int maxTombstones) {
7069
// when we delete an index, it's definitely considered to be dangling.
7170
.put(SETTING_MAX_TOMBSTONES.getKey(), maxTombstones)
7271
.put(WRITE_DANGLING_INDICES_INFO_SETTING.getKey(), true)
73-
.put(AUTO_IMPORT_DANGLING_INDICES_SETTING.getKey(), false)
7472
.build();
7573
}
7674

server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java

-66
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.elasticsearch.env.TestEnvironment;
3232
import org.elasticsearch.gateway.GatewayMetaState;
3333
import org.elasticsearch.gateway.PersistedClusterStateService;
34-
import org.elasticsearch.indices.IndicesService;
3534
import org.elasticsearch.node.Node;
3635
import org.elasticsearch.test.ESIntegTestCase;
3736
import org.elasticsearch.test.InternalTestCluster;
@@ -41,12 +40,8 @@
4140
import java.util.List;
4241
import java.util.Locale;
4342

44-
import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
45-
import static org.elasticsearch.gateway.DanglingIndicesState.AUTO_IMPORT_DANGLING_INDICES_SETTING;
46-
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
4743
import static org.elasticsearch.indices.recovery.RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING;
4844
import static org.elasticsearch.test.NodeRoles.nonMasterNode;
49-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
5045
import static org.hamcrest.Matchers.containsString;
5146
import static org.hamcrest.Matchers.equalTo;
5247
import static org.hamcrest.Matchers.notNullValue;
@@ -312,67 +307,6 @@ public void test3MasterNodes2Failed() throws Exception {
312307
ensureStableCluster(4);
313308
}
314309

315-
public void testAllMasterEligibleNodesFailedDanglingIndexImport() throws Exception {
316-
internalCluster().setBootstrapMasterNodeIndex(0);
317-
318-
Settings settings = Settings.builder()
319-
.put(AUTO_IMPORT_DANGLING_INDICES_SETTING.getKey(), true)
320-
.build();
321-
322-
logger.info("--> start mixed data and master-eligible node and bootstrap cluster");
323-
String masterNode = internalCluster().startNode(settings); // node ordinal 0
324-
325-
logger.info("--> start data-only node and ensure 2 nodes stable cluster");
326-
String dataNode = internalCluster().startDataOnlyNode(settings); // node ordinal 1
327-
ensureStableCluster(2);
328-
329-
logger.info("--> index 1 doc and ensure index is green");
330-
client().prepareIndex("test").setId("1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get();
331-
ensureGreen("test");
332-
assertBusy(() -> internalCluster().getInstances(IndicesService.class).forEach(
333-
indicesService -> assertTrue(indicesService.allPendingDanglingIndicesWritten())));
334-
335-
logger.info("--> verify 1 doc in the index");
336-
assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L);
337-
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true));
338-
339-
logger.info("--> stop data-only node and detach it from the old cluster");
340-
Settings dataNodeDataPathSettings = Settings.builder()
341-
.put(internalCluster().dataPathSettings(dataNode), true)
342-
.put(AUTO_IMPORT_DANGLING_INDICES_SETTING.getKey(), true)
343-
.build();
344-
assertBusy(() -> internalCluster().getInstance(GatewayMetaState.class, dataNode).allPendingAsyncStatesWritten());
345-
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(dataNode));
346-
final Environment environment = TestEnvironment.newEnvironment(
347-
Settings.builder()
348-
.put(internalCluster().getDefaultSettings())
349-
.put(dataNodeDataPathSettings)
350-
.put(AUTO_IMPORT_DANGLING_INDICES_SETTING.getKey(), true)
351-
.build());
352-
detachCluster(environment, false);
353-
354-
logger.info("--> stop master-eligible node, clear its data and start it again - new cluster should form");
355-
internalCluster().restartNode(masterNode, new InternalTestCluster.RestartCallback(){
356-
@Override
357-
public boolean clearData(String nodeName) {
358-
return true;
359-
}
360-
});
361-
362-
logger.info("--> start data-only only node and ensure 2 nodes stable cluster");
363-
internalCluster().startDataOnlyNode(dataNodeDataPathSettings);
364-
ensureStableCluster(2);
365-
366-
logger.info("--> verify that the dangling index exists and has green status");
367-
assertBusy(() -> {
368-
assertThat(indexExists("test"), equalTo(true));
369-
});
370-
ensureGreen("test");
371-
372-
logger.info("--> verify the doc is there");
373-
assertThat(client().prepareGet("test", "1").execute().actionGet().isExists(), equalTo(true));
374-
}
375-
376310
public void testNoInitialBootstrapAfterDetach() throws Exception {
377311
internalCluster().setBootstrapMasterNodeIndex(0);
378312
String masterNode = internalCluster().startMasterOnlyNode();

0 commit comments

Comments
 (0)