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

Ignore dangling indices created in newer versions #48652

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public ClusterState execute(ClusterState currentState) {
minIndexCompatibilityVersion);
continue;
}
if (currentState.nodes().getMinNodeVersion().before(indexMetaData.getCreationVersion())) {
logger.warn("ignoring dangled index [{}] on node [{}]" +
" since its created version [{}] is later than the oldest versioned node in the cluster [{}]",
indexMetaData.getIndex(), request.fromNode, indexMetaData.getCreationVersion(),
currentState.getNodes().getMasterNode().getVersion());
continue;
}
if (currentState.metaData().hasIndex(indexMetaData.getIndex().getName())) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,28 @@ public void testDanglingIndicesWithAliasConflict() throws Exception {
assertNotNull(clusterService.state().getMetaData().index(alias));
}

public void testDanglingIndicesWithLaterVersion() throws Exception {
final String indexNameLater = "test-idxnewer";
final ClusterService clusterService = getInstanceFromNode(ClusterService.class);
final ClusterState originalState = clusterService.state();

//import an index with minor version incremented by one over cluster master version, it should be ignored
final LocalAllocateDangledIndices dangling = getInstanceFromNode(LocalAllocateDangledIndices.class);
final Settings idxSettingsLater = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED,
Version.fromId(Version.CURRENT.id + 10000))
.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.build();
final IndexMetaData indexMetaDataLater = new IndexMetaData.Builder(indexNameLater)
.settings(idxSettingsLater)
.numberOfShards(1)
.numberOfReplicas(0)
.build();
CountDownLatch latch = new CountDownLatch(1);
dangling.allocateDangled(Arrays.asList(indexMetaDataLater), ActionListener.wrap(latch::countDown));
latch.await();
assertThat(clusterService.state(), equalTo(originalState));
}

/**
* This test checks an edge case where, if a node had an index (lets call it A with UUID 1), then
* deleted it (so a tombstone entry for A will exist in the cluster state), then created
Expand Down