mirror of
https://github.com/apache/lucene.git
synced 2025-02-10 03:55:46 +00:00
:SOLR-13454: Investigate ReindexCollectionTest failures, added more safeguards in bandaid code
(cherry picked from commit 4f8998714174752e8cff125e1fad49d73edcd331)
This commit is contained in:
parent
d353c19f77
commit
e6892683a2
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user