SOLR-11426: TestLazyCores fails too often, debugging

This commit is contained in:
Erick 2017-11-21 09:55:40 -08:00
parent 0dadf2c2a8
commit ab5fbad3d7
4 changed files with 25 additions and 18 deletions

View File

@ -19,17 +19,12 @@ package org.apache.solr.core;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.http.annotation.Experimental; import org.apache.http.annotation.Experimental;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.logging.MDCLoggingContext; import org.apache.solr.logging.MDCLoggingContext;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.DefaultSolrThreadFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -539,21 +534,22 @@ class SolrCores implements Observer {
return false; return false;
} }
// Let transient cache implementation tell us when it ages out a corel // Let transient cache implementation tell us when it ages out a core
@Override @Override
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
synchronized (modifyLock) { synchronized (modifyLock) {
SolrCore core = (SolrCore) arg; // Erick Erickson debugging TestLazyCores. With this un-commented, we get no testLazyCores failures.
SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams()); // SolrCore core = (SolrCore) arg;
CommitUpdateCommand cmd = new CommitUpdateCommand(req, false); // SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
cmd.openSearcher = false; // CommitUpdateCommand cmd = new CommitUpdateCommand(req, false);
cmd.waitSearcher = false; // cmd.openSearcher = false;
try { // cmd.waitSearcher = false;
core.getUpdateHandler().commit(cmd); // try {
} catch (IOException e) { // core.getUpdateHandler().commit(cmd);
log.warn("Caught exception trying to close a transient core, ignoring as it should be benign"); // } catch (IOException e) {
} // log.warn("Caught exception trying to close a transient core, ignoring as it should be benign");
pendingCloses.add(core); // Essentially just queue this core up for closing. // }
pendingCloses.add((SolrCore) arg); // Essentially just queue this core up for closing.
modifyLock.notifyAll(); // Wakes up closer thread too modifyLock.notifyAll(); // Wakes up closer thread too
} }
} }

View File

@ -813,7 +813,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
@Override @Override
public void close() throws IOException { public void close() throws IOException {
log.debug("closing " + this); log.debug("closing " + this);
commitTracker.close(); commitTracker.close();
softCommitTracker.close(); softCommitTracker.close();

View File

@ -43,4 +43,7 @@ A solrconfig.xml snippet containing indexConfig settings for randomized testing.
to vary the lockType canset it as needed. to vary the lockType canset it as needed.
--> -->
<lockType>${solr.tests.lockType:single}</lockType> <lockType>${solr.tests.lockType:single}</lockType>
<infoStream>${solr.tests.infostream:false}</infoStream>
</indexConfig> </indexConfig>

View File

@ -786,6 +786,9 @@ public class TestLazyCores extends SolrTestCaseJ4 {
// Cores 2, 3, 6, 7, 8, 9 are transient // Cores 2, 3, 6, 7, 8, 9 are transient
@Test @Test
public void testNoCommit() throws Exception { public void testNoCommit() throws Exception {
String infoStream = System.getProperty("solr.tests.infostream");
System.setProperty("solr.tests.infostream","true");
CoreContainer cc = init(); CoreContainer cc = init();
String[] coreList = new String[]{ String[] coreList = new String[]{
"collection2", "collection2",
@ -832,6 +835,11 @@ public class TestLazyCores extends SolrTestCaseJ4 {
} finally { } finally {
cc.shutdown(); cc.shutdown();
} }
if (infoStream != null) {
System.setProperty("solr.tests.infostream", infoStream);
} else {
System.clearProperty("solr.tests.infostream");
}
} }
private void add10(SolrCore core) throws IOException { private void add10(SolrCore core) throws IOException {