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

[GitHub] [solr] justinrsweeney opened a new pull request, #1437: SOLR-16487: Improve Pull Replica Interval

justinrsweeney opened a new pull request, #1437:
URL: https://github.com/apache/solr/pull/1437

   https://issues.apache.org/jira/browse/SOLR-16487
   
   # Description
   
   The polling for replication is fairly simply, but can lead to polling too often. As an example if you had the following config for commits:
   ```
   <autoCommit>
       <maxTime>15000</maxTime>
       <openSearcher>false</openSearcher>
   </autoCommit>
   
   <autoSoftCommit>
       <maxTime>60000</maxTime>
   </autoSoftCommit>
   ```
   The current logic would setup polling to be half of the autoCommit time, so poll every 7.5 seconds. However since a new searcher isn't opened, there will only be changes reflected every 60 seconds on the leader. We can make this logic a bit smarter knowing that the replication handler won't reflect changes until a new searcher is opened.
   
   # Solution
   
   Modified the code setting the polling interval for replication to only use the autoCommit time if openSearcher is true, otherwise it will use the soft commit time.
   
   # Tests
   
   Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
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


[GitHub] [solr] justinrsweeney closed pull request #1437: SOLR-16487: Improve Pull Replica Interval

Posted by "justinrsweeney (via GitHub)" <gi...@apache.org>.
justinrsweeney closed pull request #1437: SOLR-16487: Improve Pull Replica Interval
URL: https://github.com/apache/solr/pull/1437


-- 
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


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

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
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


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

Posted by "justinrsweeney (via GitHub)" <gi...@apache.org>.
justinrsweeney commented on code in PR #1437:
URL: https://github.com/apache/solr/pull/1437#discussion_r1132635854


##########
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:
   No good reason, thanks for pointing that out.



-- 
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


[GitHub] [solr] justinrsweeney merged pull request #1437: SOLR-16487: Improve Pull Replica Interval

Posted by "justinrsweeney (via GitHub)" <gi...@apache.org>.
justinrsweeney merged PR #1437:
URL: https://github.com/apache/solr/pull/1437


-- 
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