You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2019/09/29 16:26:03 UTC

[lucene-solr] branch master updated: :SOLR-13454: Investigate ReindexCollectionTest failures, added more safeguards in bandaid code

This is an automated email from the ASF dual-hosted git repository.

erick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 4f89987  :SOLR-13454: Investigate ReindexCollectionTest failures, added more safeguards in bandaid code
4f89987 is described below

commit 4f8998714174752e8cff125e1fad49d73edcd331
Author: Erick Erickson <Er...@gmail.com>
AuthorDate: Sun Sep 29 12:25:43 2019 -0400

    :SOLR-13454: Investigate ReindexCollectionTest failures, added more safeguards in bandaid code
---
 .../src/java/org/apache/solr/SolrTestCaseJ4.java   | 39 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 21a91ee..9020366 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -121,6 +121,7 @@ import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.ObjectReleaseTracker;
 import org.apache.solr.common.util.SolrjNamedThreadFactory;
 import org.apache.solr.common.util.SuppressForbidden;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.common.util.XML;
 import org.apache.solr.core.CoreContainer;
@@ -152,6 +153,7 @@ import org.apache.solr.util.SSLTestConfig;
 import org.apache.solr.util.StartupLoggingUtils;
 import org.apache.solr.util.TestHarness;
 import org.apache.solr.util.TestInjection;
+import org.apache.solr.util.TimeOut;
 import org.apache.zookeeper.KeeperException;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -3116,7 +3118,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
     QueryResponse rsp = client.query(collection, solrQuery);
     long found = rsp.getResults().getNumFound();
 
-    if (rsp.getResults().getNumFound() == expectedDocCount) {
+    if (found == expectedDocCount) {
       return;
     }
 
@@ -3131,9 +3133,17 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
     // Add the bogus doc
     new UpdateRequest().add(bogus).commit(client, collection);
 
+    // Let's spin until we find the doc.
+    checkUniqueDoc(client, collection, idField, bogusID, true);
+
     // Then remove it, we should be OK now since new searchers have been opened.
     new UpdateRequest().deleteById(bogusID).commit(client, collection);
-    // Let's check again to see if we succeeded
+
+    // Now spin until the doc is gone.
+    checkUniqueDoc(client, collection, idField, bogusID, false);
+
+    // At this point we're absolutely, totally, positive that a new searcher has been opened, so go ahead and check
+    // the actual condition.
     rsp = client.query(collection, solrQuery);
     found = rsp.getResults().getNumFound();
 
@@ -3145,6 +3155,31 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
     } else if (failAnyway) {
       fail("Solr11035BandAid failAnyway == true, would have successfully repaired the collection: '" + collection
           + "' extra info: '" + tag + "'");
+    } else {
+      log.warn("Solr11035BandAid, repair successful");
+    }
+  }
+  // Helper for bandaid
+  private static void checkUniqueDoc(SolrClient client, String collection, String idField, String id, boolean shouldBeThere) throws IOException, SolrServerException {
+    TimeOut timeOut = new TimeOut(100, TimeUnit.SECONDS, TimeSource.NANO_TIME);
+    final SolrQuery solrQuery = new SolrQuery(idField + ":" + id);
+
+    while (!timeOut.hasTimedOut()) {
+      QueryResponse rsp = client.query(collection, solrQuery);
+      long found = rsp.getResults().getNumFound();
+      if (shouldBeThere && found == 1) {
+        return;
+      }
+      if (shouldBeThere == false && found == 0) {
+        return;
+      }
+      log.warn("Solr11035BandAid should have succeeded in checkUniqueDoc, shouldBeThere == {}, numFound = {}. Will try again after 250 ms sleep", shouldBeThere, found);
+      try {
+        Thread.sleep(250);
+      } catch (InterruptedException e) {
+        return; // just bail
+      }
     }
+
   }
 }