A transport put follow-action can be triggered for an index that is part of a data stream and already exists.
Normally this is not an issue because the restore operation will just fail because the index already exists.
If however, the index is currently closed (for example due to ILM doing a force-merge with codec change step on the index),
this causes the currently closed index to be restored into. As a result we run into a bug in the following code in

`org.elasticsearch.xpack.ccr.action.TransportPutFollowAction#createFollowerIndex`:

```java
BiConsumer<ClusterState, Metadata.Builder> updater = (currentState, mdBuilder) -> {
   DataStream localDataStream = currentState.getMetadata().dataStreams().get(remoteDataStream.getName());
   Index followerIndex = mdBuilder.get(followerIndexName).getIndex();
   assert followerIndex != null;

   DataStream updatedDataStream = updateLocalDataStream(followerIndex, localDataStream, remoteDataStream);
      mdBuilder.put(updatedDataStream);
   };
   restoreService.restoreSnapshot(restoreRequest, delegatelistener, updater);
 }
```

This code updates the local data stream when following an index without checking if that index already is part of the data stream, thus now creating two entries for the same `Index` in the data stream's indices list. Code like `org.elasticsearch.cluster.metadata.DataStream#removeBackingIndex` however assumes no duplicates and will when deleting an index, only remove it from the data stream once. Thus leaving a dangling `Index` instance that does not point to any existing index any more, corrupting the cluster state.


cc @martijnvg thanks for the help with reasoning this out
server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java
boolean allowCustomRouting,
        IndexMode indexMode
    ) {
        this.name = name;
        this.indices = Collections.unmodifiableList(indices);
        this.generation = generation;
        this.metadata = metadata;
        assert system == false || hidden; 
        this.hidden = hidden;
        this.replicated = replicated;
        this.timeProvider = timeProvider;
        this.system = system;
        this.allowCustomRouting = allowCustomRouting;
        this.indexMode = indexMode;
        assert indices.size() > 0;
    }
    public String getName() {
        return name;
    }
    public TimestampField getTimeStampField() {
        
        return TIMESTAMP_FIELD;
    }
    public List<Index> getIndices() {
        return indices;
    }
    public long getGeneration() {
        return generation;
    }
    public Index getWriteIndex() {