Import replicated closed dangling indices (#50649)
Dangling replicated closed indices are not imported properly (they miss their routing table when imported).
This commit is contained in:
parent
b1ff74f652
commit
f203c2b39d
|
@ -510,7 +510,7 @@ public class RoutingTable implements Iterable<IndexRoutingTable>, Diffable<Routi
|
|||
}
|
||||
|
||||
public Builder addAsFromDangling(IndexMetaData indexMetaData) {
|
||||
if (indexMetaData.getState() == IndexMetaData.State.OPEN) {
|
||||
if (indexMetaData.getState() == IndexMetaData.State.OPEN || isIndexVerifiedBeforeClosed(indexMetaData)) {
|
||||
IndexRoutingTable.Builder indexRoutingBuilder = new IndexRoutingTable.Builder(indexMetaData.getIndex())
|
||||
.initializeAsFromDangling(indexMetaData);
|
||||
add(indexRoutingBuilder);
|
||||
|
|
|
@ -51,6 +51,8 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.elasticsearch.cluster.metadata.MetaDataIndexStateService.isIndexVerifiedBeforeClosed;
|
||||
|
||||
public class LocalAllocateDangledIndices {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(LocalAllocateDangledIndices.class);
|
||||
|
@ -149,7 +151,7 @@ public class LocalAllocateDangledIndices {
|
|||
}
|
||||
metaData.put(upgradedIndexMetaData, false);
|
||||
blocks.addBlocks(upgradedIndexMetaData);
|
||||
if (upgradedIndexMetaData.getState() == IndexMetaData.State.OPEN) {
|
||||
if (upgradedIndexMetaData.getState() == IndexMetaData.State.OPEN || isIndexVerifiedBeforeClosed(indexMetaData)) {
|
||||
routingTableBuilder.addAsFromDangling(upgradedIndexMetaData);
|
||||
}
|
||||
sb.append("[").append(upgradedIndexMetaData.getIndex()).append("/").append(upgradedIndexMetaData.getState())
|
||||
|
|
|
@ -53,6 +53,11 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
|||
|
||||
createIndex(INDEX_NAME, Settings.builder().put("number_of_replicas", 2).build());
|
||||
|
||||
if (randomBoolean()) {
|
||||
client().admin().indices().prepareClose(INDEX_NAME).get();
|
||||
}
|
||||
ensureGreen(INDEX_NAME);
|
||||
|
||||
// Restart node, deleting the index in its absence, so that there is a dangling index to recover
|
||||
internalCluster().restartRandomDataNode(new InternalTestCluster.RestartCallback() {
|
||||
|
||||
|
@ -64,6 +69,7 @@ public class DanglingIndicesIT extends ESIntegTestCase {
|
|||
});
|
||||
|
||||
assertBusy(() -> assertTrue("Expected dangling index " + INDEX_NAME + " to be recovered", indexExists(INDEX_NAME)));
|
||||
ensureGreen(INDEX_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue