title: How to force a leader on SolrCloud?
body: <p>I have a 5-node SolrCloud (Solr 7.0) with an external 3-node Zookeeper ensemble. There is one collection called "production" that is sharded to 5 shards with a replication factor of 5. See the screenshot below:</p>
  
  <p><a href="https://i.stack.imgur.com/WyB2N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WyB2N.png" alt="enter image description here"></a></p>
  
  <p>shard5 was struggling to elect a new leader for a long time and other cores were complaining with the following error:</p>
  
  <blockquote>
    <p>azsolr1 solr: 2018-08-28 19:32:43.575 ERROR (qtp1124317168-9304) [c:production s:shard2 r:core_node9 x:production_shard2_replica_n4] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: No registered leader was found after waiting for 4000ms , collection: production slice: shard5</p>
  </blockquote>
  
  <p>After restarting all nodes one by one (I even restarted the zookeeper nodes), I had no luck in electing the only active replica (azsolr1) as the leader. I then unloaded the 4 replicas with the 'down' state using the <a href="https://lucene.apache.org/solr/guide/6_6/coreadmin-api.html#CoreAdminAPI-UNLOAD" rel="nofollow noreferrer">CoreAdmin API UNLOAD</a> command which caused the replicas to disappear completely.</p>
  
  <p>With that setup, trying to force the leader of the shard using the <a href="https://lucene.apache.org/solr/guide/6_6/collections-api.html#CollectionsAPI-forceleader" rel="nofollow noreferrer">Collection API FORCELEADER</a> does nothing. I also tried this before unloading the cores.</p>
  
  <p>Here is the current status:</p>
  
  <p><a href="https://i.stack.imgur.com/WAPn6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WAPn6.png" alt="enter image description here"></a></p>
  
  <p>Why can't Solr just elect the only active replica for shard 5 as the leader? Isn't this obvious, especially after forcing the leader on the shard?</p>
  
  <p>Assuming the leader was elected successfully somehow, do I recreate the replicas that I deleted using the <a href="https://lucene.apache.org/solr/guide/6_6/collections-api.html#CollectionsAPI-addreplica" rel="nofollow noreferrer">Collection API ADDREPLICA</a>? In this case, should I reuse the same <code>instanceDir</code> and <code>dataDir</code> of the deleted replicas? Or I just let it replicate from scratch?</p>