Skip to content

Commit 413ce1c

Browse files
authored
Protect against the leader index being removed (#39351)
when dealing with TimeoutException The `IndexFollowingIT#testDeleteLeaderIndex()`` test failed, because a NPE was captured as fatal error instead of an IndexNotFoundException. Closes #39308
1 parent 663bffa commit 413ce1c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardChangesAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.common.io.stream.StreamOutput;
2525
import org.elasticsearch.common.unit.ByteSizeValue;
2626
import org.elasticsearch.common.unit.TimeValue;
27+
import org.elasticsearch.index.IndexNotFoundException;
2728
import org.elasticsearch.index.IndexService;
2829
import org.elasticsearch.index.IndexSettings;
2930
import org.elasticsearch.index.engine.MissingHistoryOperationsException;
@@ -418,6 +419,11 @@ private void globalCheckpointAdvancementFailure(
418419
if (e instanceof TimeoutException) {
419420
try {
420421
final IndexMetaData indexMetaData = clusterService.state().metaData().index(shardId.getIndex());
422+
if (indexMetaData == null) {
423+
listener.onFailure(new IndexNotFoundException(shardId.getIndex()));
424+
return;
425+
}
426+
421427
final long mappingVersion = indexMetaData.getMappingVersion();
422428
final long settingsVersion = indexMetaData.getSettingsVersion();
423429
final SeqNoStats latestSeqNoStats = indexShard.seqNoStats();

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ public void testCloseFollowIndex() throws Exception {
660660
pauseFollow("index2");
661661
}
662662

663-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39308")
664663
public void testDeleteLeaderIndex() throws Exception {
665664
assertAcked(leaderClient().admin().indices().prepareCreate("index1")
666665
.setSettings(Settings.builder()

0 commit comments

Comments
 (0)