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
This commit is contained in:
Martijn van Groningen 2019-02-25 13:39:32 +01:00
parent 9d97f3289d
commit 6f69ef165b
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.engine.MissingHistoryOperationsException;
@ -418,6 +419,11 @@ public class ShardChangesAction extends Action<ShardChangesAction.Response> {
if (e instanceof TimeoutException) {
try {
final IndexMetaData indexMetaData = clusterService.state().metaData().index(shardId.getIndex());
if (indexMetaData == null) {
listener.onFailure(new IndexNotFoundException(shardId.getIndex()));
return;
}
final long mappingVersion = indexMetaData.getMappingVersion();
final long settingsVersion = indexMetaData.getSettingsVersion();
final SeqNoStats latestSeqNoStats = indexShard.seqNoStats();