dsmiley commented on code in PR #4237:
URL: https://github.com/apache/solr/pull/4237#discussion_r3012395268
##########
solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java:
##########
@@ -707,6 +711,55 @@ private QueryResponse queryWithAsserts(String... q) throws
Exception {
return response;
}
+ /**
+ * When a node resolves collection state for a collection it doesn't host,
queries should use
+ * cached state and not make ZK calls on every query.
+ */
+ @Test
+ public void testDistributedQueryDoesNotReadFromZk() throws Exception {
+ final String testCollection = "testCollection";
Review Comment:
Naming this "secondColl" would be much clearer. All collections in tests
are "test" collections ;-)
##########
solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentOptimizationTest.java:
##########
@@ -707,6 +711,55 @@ private QueryResponse queryWithAsserts(String... q) throws
Exception {
return response;
}
+ /**
+ * When a node resolves collection state for a collection it doesn't host,
queries should use
+ * cached state and not make ZK calls on every query.
+ */
+ @Test
+ public void testDistributedQueryDoesNotReadFromZk() throws Exception {
+ final String testCollection = "testCollection";
+
+ // Create a collection on only 1 node so the other node uses
LazyCollectionRef for state
+ List<JettySolrRunner> jettys = cluster.getJettySolrRunners();
+ CollectionAdminRequest.createCollection(testCollection, "conf", 1, 1)
+ .setCreateNodeSet(jettys.get(0).getNodeName())
+ .processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);
+ cluster
+ .getZkStateReader()
+ .waitForState(
+ testCollection,
+ DEFAULT_TIMEOUT,
+ TimeUnit.SECONDS,
+ (n, c) -> SolrCloudTestCase.replicasForCollectionAreFullyActive(n,
c, 1, 1));
+
+ try {
+ // Node 1 hosts COLLECTION but not testCollection.
+ // Send a multi-collection query to trigger LazyCollectionRef get call
+ JettySolrRunner nodeWithoutOther = jettys.get(1);
+ try (SolrClient client =
+ new
HttpJettySolrClient.Builder(nodeWithoutOther.getBaseUrl().toString()).build()) {
+
+ String collectionsParameter = COLLECTION + "," + testCollection;
+
+ // Warm up LazyCollectionRef state cache with query
+ client.query(COLLECTION, new SolrQuery("q", "*:*", "collection",
collectionsParameter));
+
Review Comment:
this only looks at the metrics on one node, and it's not obvious what node
that is. A comment could clarify or actually get it from the pertinent jetty
(the one you will query, the coordinator).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]