SOLR-10734: AtomicUpdateProcessorFactoryTest was not truly multithreaded

This commit is contained in:
Noble Paul 2017-07-27 15:27:58 +09:30
parent 1582509d04
commit edff113e13
2 changed files with 8 additions and 9 deletions

View File

@ -63,7 +63,7 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactory
private final static String VERSION = "_version_";
public static final String NAME = "atomic";
public final static String ATOMIC_FIELD_PREFIX = "atomic.";
private final static int MAX_ATTEMPTS = 5;
private final static int MAX_ATTEMPTS = 25;
private VersionInfo vinfo;
@ -165,7 +165,7 @@ public class AtomicUpdateProcessorFactory extends UpdateRequestProcessorFactory
try {
super.processAdd(cmd);
} catch (SolrException e) {
if (attempts++ >= MAX_ATTEMPTS) {//maximum number of attempts allowed: 5
if (attempts++ >= MAX_ATTEMPTS) {//maximum number of attempts allowed: 25
throw new SolrException(SERVER_ERROR,
"Atomic update failed after multiple attempts due to " + e.getMessage());
}

View File

@ -209,7 +209,10 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
List<Thread> threads = new ArrayList<>(100);
int finalCount = 0; //int_i
for (int i = 0; i < 100; i++) {
AtomicUpdateProcessorFactory factory = new AtomicUpdateProcessorFactory();
factory.inform(h.getCore());
for (int i = 0; i < 10; i++) {
int index = random().nextInt(5);
Thread t = new Thread() {
@Override
@ -229,8 +232,6 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
cmd.solrDoc.addField("int_i", index);
try {
AtomicUpdateProcessorFactory factory = new AtomicUpdateProcessorFactory();
factory.inform(h.getCore());
factory.getInstance(cmd.getReq(), new SolrQueryResponse(),
new DistributedUpdateProcessor(cmd.getReq(), new SolrQueryResponse(),
new RunUpdateProcessor(cmd.getReq(), null))).processAdd(cmd);
@ -238,14 +239,12 @@ public class AtomicUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
}
}
};
t.run();
threads.add(t);
t.start();
finalCount += index; //int_i
}
for (Thread thread: threads) {
thread.join();
}
for (Thread thread: threads) thread.join();
assertU(commit());