SOLR-13882: Collections API COLSTATUS does not check live_nodes when reporting replica's status.

This commit is contained in:
Andrzej Bialecki 2019-11-05 14:06:05 +01:00
parent e58a90f18d
commit 720fb94113
3 changed files with 22 additions and 0 deletions

View File

@ -153,6 +153,9 @@ Bug Fixes
* SOLR-13762: Fix BinaryField support for non-binary wt's (Thomas Woeckinger via Jason Gerlowski)
* SOLR-13882: Collections API COLSTATUS does not check live_nodes when reporting replica's status.
(Erick Erickson, Andrzej Białecki)
Other Changes
---------------------

View File

@ -123,6 +123,11 @@ public class ColStatus {
int recoveringReplicas = 0;
int recoveryFailedReplicas = 0;
for (Replica r : s.getReplicas()) {
// replica may still be marked as ACTIVE even though its node is no longer live
if (! r.isActive(clusterState.getLiveNodes())) {
downReplicas++;
continue;
}
switch (r.getState()) {
case ACTIVE:
activeReplicas++;

View File

@ -43,6 +43,7 @@ import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@ -658,6 +659,19 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
assertNotNull(Utils.toJSONString(rsp), segInfos.get("fieldInfoLegend"));
assertNotNull(Utils.toJSONString(rsp), segInfos.findRecursive("segments", "_0", "fields", "id", "flags"));
assertNotNull(Utils.toJSONString(rsp), segInfos.findRecursive("segments", "_0", "ramBytesUsed"));
// test for replicas not active - SOLR-13882
DocCollection coll = cluster.getSolrClient().getClusterStateProvider().getClusterState().getCollection(collectionName);
Replica firstReplica = coll.getSlice("shard1").getReplicas().iterator().next();
String firstNode = firstReplica.getNodeName();
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
if (jetty.getNodeName().equals(firstNode)) {
cluster.stopJettySolrRunner(jetty);
}
}
rsp = req.process(cluster.getSolrClient());
assertEquals(0, rsp.getStatus());
Number down = (Number) rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "replicas", "down");
assertTrue("should be some down replicas, but there were none in shard1:" + rsp, down.intValue() > 0);
}
private static final int NUM_DOCS = 10;