You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2023/03/09 20:34:56 UTC

[GitHub] [solr] dsmiley commented on a diff in pull request #1437: SOLR-16487: Improve Pull Replica Interval

dsmiley commented on code in PR #1437:
URL: https://github.com/apache/solr/pull/1437#discussion_r1131559894


##########
solr/core/src/java/org/apache/solr/cloud/ReplicateFromLeader.java:
##########
@@ -155,6 +155,38 @@ public static String getCommitVersion(SolrCore solrCore) {
     }
   }
 
+  public static String determinePollInterval(SolrConfig.UpdateHandlerInfo uinfo) {
+    int hardCommitMaxTime = uinfo.autoCommmitMaxTime;
+    int softCommitMaxTime = uinfo.autoSoftCommmitMaxTime;
+    boolean hardCommitNewSearcher = uinfo.openSearcher;
+    String pollIntervalStr = null;
+    if (hardCommitMaxTime != -1) {
+      // configured hardCommit places a ceiling on the interval at which new segments will be
+      // available

Review Comment:
   Code comments need to be re-flowed after "tidy" did its work.
   When writing comments that flow to this many lines (kind of a lot) consider /* */ style, which I *think* Tidy reflows for you.



##########
solr/core/src/java/org/apache/solr/cloud/ReplicateFromLeader.java:
##########
@@ -155,6 +155,38 @@ public static String getCommitVersion(SolrCore solrCore) {
     }
   }
 
+  public static String determinePollInterval(SolrConfig.UpdateHandlerInfo uinfo) {
+    int hardCommitMaxTime = uinfo.autoCommmitMaxTime;
+    int softCommitMaxTime = uinfo.autoSoftCommmitMaxTime;
+    boolean hardCommitNewSearcher = uinfo.openSearcher;
+    String pollIntervalStr = null;
+    if (hardCommitMaxTime != -1) {
+      // configured hardCommit places a ceiling on the interval at which new segments will be
+      // available
+      // to replicate
+      if (softCommitMaxTime != -1
+          && (!hardCommitNewSearcher || softCommitMaxTime <= hardCommitMaxTime)) {
+        // softCommit is configured.
+        // Usually if softCommit is configured, `hardCommitNewSearcher==false`, in which case you
+        // want
+        // to calculate poll interval wrt the max of hardCommitTime (when segments are available to
+        // replicate) and softCommitTime (when changes are visible).
+        // But in the unusual case that hardCommit _does_ open a new searcher and
+        // `hardCommitMaxTime < softCommitMaxTime`, then fallback to `else` clause, setting poll
+        // interval
+        // wrt `hardCommitMaxTime` alone.
+        pollIntervalStr = toPollIntervalStr((Math.max(hardCommitMaxTime, softCommitMaxTime)) / 2);

Review Comment:
   nitpick: extra parentheses in here that are not adding clarity at all



##########
solr/core/src/test/org/apache/solr/cloud/ReplicateFromLeaderTest.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.cloud;
+
+import org.apache.solr.core.SolrConfig;
+import org.junit.Test;
+
+public class ReplicateFromLeaderTest extends SolrCloudTestCase {

Review Comment:
   Why SolrCloudTestCase?



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org