SOLR-3428: SolrCmdDistributor flushAdds/flushDeletes can cause repeated adds/deletes to be sent

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1368590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-08-02 16:33:43 +00:00
parent ad2cefee00
commit 6a88e3239f
3 changed files with 51 additions and 3 deletions

View File

@ -221,7 +221,7 @@ public class SolrCmdDistributor {
for (Node node : nodes) { for (Node node : nodes) {
List<AddRequest> alist = adds.get(node); List<AddRequest> alist = adds.get(node);
if (alist == null || alist.size() < limit) return false; if (alist == null || alist.size() < limit) continue;
UpdateRequestExt ureq = new UpdateRequestExt(); UpdateRequestExt ureq = new UpdateRequestExt();

View File

@ -39,4 +39,6 @@
</updateLog> </updateLog>
</updateHandler> </updateHandler>
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
</config> </config>

View File

@ -24,13 +24,16 @@ import java.util.List;
import org.apache.solr.BaseDistributedSearchTestCase; import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.LukeRequest;
import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.SolrCmdDistributor.Node; import org.apache.solr.update.SolrCmdDistributor.Node;
import org.apache.solr.update.SolrCmdDistributor.Response; import org.apache.solr.update.SolrCmdDistributor.Response;
import org.apache.solr.update.SolrCmdDistributor.StdNode; import org.apache.solr.update.SolrCmdDistributor.StdNode;
@ -40,7 +43,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
public SolrCmdDistributorTest() { public SolrCmdDistributorTest() {
fixShardCount = true; fixShardCount = true;
shardCount = 1; shardCount = 4;
stress = 0; stress = 0;
} }
@ -80,7 +83,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
@Override @Override
public void doTest() throws Exception { public void doTest() throws Exception {
//del("*:*"); del("*:*");
SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(8); SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(8);
@ -159,6 +162,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
assertEquals(response.errors.toString(), 0, response.errors.size()); assertEquals(response.errors.toString(), 0, response.errors.size());
results = controlClient.query(new SolrQuery("*:*")).getResults(); results = controlClient.query(new SolrQuery("*:*")).getResults();
numFound = results.getNumFound(); numFound = results.getNumFound();
assertEquals(results.toString(), 2, numFound); assertEquals(results.toString(), 2, numFound);
@ -166,5 +170,47 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
numFound = client.query(new SolrQuery("*:*")).getResults() numFound = client.query(new SolrQuery("*:*")).getResults()
.getNumFound(); .getNumFound();
assertEquals(results.toString(), 2, numFound); assertEquals(results.toString(), 2, numFound);
// debug stuff
// for (SolrServer c : clients) {
// c.optimize();
// System.out.println(clients.get(0).request(new LukeRequest()));
// }
int id = 5;
cmdDistrib = new SolrCmdDistributor(8);
nodes.clear();
int cnt = atLeast(200);
for (int i = 0; i < cnt; i++) {
nodes.clear();
for (SolrServer c : clients) {
if (random().nextBoolean()) {
continue;
}
HttpSolrServer httpClient = (HttpSolrServer) c;
nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP,
httpClient.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
nodes.add(new StdNode(new ZkCoreNodeProps(nodeProps)));
}
cmd.solrDoc = sdoc("id", id++);
cmdDistrib.distribAdd(cmd, nodes, params);
}
cmdDistrib.finish();
cmdDistrib.distribCommit(ccmd, nodes, params);
for (SolrServer c : clients) {
NamedList<Object> resp = c.request(new LukeRequest());
System.out.println(resp);
assertEquals("SOLR-3428: We only did adds - there should be no deletes",
((NamedList<Object>) resp.get("index")).get("numDocs"),
((NamedList<Object>) resp.get("index")).get("maxDoc"));
}
} }
} }