Skip to content

Apache Lucene open-source search software

SOLR-3755: Treat no live SolrServers available as a recoverable error and count document to avoid spurious failures

Shalin Shekhar Mangar7114859f09ce
diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
index 57bf0184a05..9bbc2399928 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ShardSplitTest.java
@@ -197,15 +197,29 @@ public class ShardSplitTest extends BasicDistributedZkTest {
}
protected void indexAndUpdateCount(List<DocRouter.Range> ranges, int[] docCounts, int id) throws Exception {
- indexr("id", id);
-
- // todo - hook in custom hashing
- byte[] bytes = String.valueOf(id).getBytes("UTF-8");
- int hash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
- for (int i = 0; i < ranges.size(); i++) {
- DocRouter.Range range = ranges.get(i);
- if (range.includes(hash))
- docCounts[i]++;
+ boolean success = true;
+ try {
+ indexr("id", id);
+ } catch (SolrServerException e) {
+ if (!e.getMessage().startsWith("No live SolrServers available to handle this request")) {
+ success = false;
+ log.error("Exception while adding doc", e);
+ } else {
+ // Error is recoverable because the proxy node will store the request in its log and
+ // it will be retried later and sent to the leader
+ log.warn("Counting doc: " + id + " because error is recoverable", e);
+ }
+ } finally {
+ if (success) {
+ // todo - hook in custom hashing
+ byte[] bytes = String.valueOf(id).getBytes("UTF-8");
+ int hash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
+ for (int i = 0; i < ranges.size(); i++) {
+ DocRouter.Range range = ranges.get(i);
+ if (range.includes(hash))
+ docCounts[i]++;
+ }
+ }
}
}