You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by cp...@apache.org on 2023/09/01 14:45:49 UTC

[solr] branch branch_9x updated (0a764f0a732 -> 1a56cf17a6d)

This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


    from 0a764f0a732 SOLR-16958: Fix spurious warning about LATEST luceneMatchVersion (#1879)
     new 73698676986 NO JIRA: factor out protected SearchHandler.checkCircuitBreakers method (#1882)
     new 1a56cf17a6d NO JIRA: add TestFieldValueFeature.testBooleanValue_docValues() case (#1881)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../solr/handler/component/SearchHandler.java      | 64 ++++++++++++++--------
 .../solr/ltr/feature/TestFieldValueFeature.java    | 15 ++++-
 2 files changed, 54 insertions(+), 25 deletions(-)


[solr] 01/02: NO JIRA: factor out protected SearchHandler.checkCircuitBreakers method (#1882)

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 73698676986fda0607367a672266da3519e0b980
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Fri Sep 1 15:37:39 2023 +0100

    NO JIRA: factor out protected SearchHandler.checkCircuitBreakers method (#1882)
    
    (cherry picked from commit 199d51f1a3fe6188b405ef99f8f75ddd54729f6a)
---
 .../solr/handler/component/SearchHandler.java      | 64 ++++++++++++++--------
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index 5b5672faf8d..0d5b6c27c00 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -329,29 +329,14 @@ public class SearchHandler extends RequestHandlerBase
     return new ResponseBuilder(req, rsp, components);
   }
 
-  @Override
-  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
-    if (req.getParams().getBool(ShardParams.IS_SHARD, false)) {
-      int purpose = req.getParams().getInt(ShardParams.SHARDS_PURPOSE, 0);
-      SolrPluginUtils.forEachRequestPurpose(
-          purpose, n -> shardPurposes.computeIfAbsent(n, name -> new Counter()).inc());
-    }
-
-    List<SearchComponent> components = getComponents();
-    ResponseBuilder rb = newResponseBuilder(req, rsp, components);
-    if (rb.requestInfo != null) {
-      rb.requestInfo.setResponseBuilder(rb);
-    }
-
-    rb.isDistrib = isDistrib(req);
-    tagRequestWithRequestId(rb);
-
-    boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
-    rb.setDebug(dbg);
-    if (dbg == false) { // if it's true, we are doing everything anyway.
-      SolrPluginUtils.getDebugInterests(req.getParams().getParams(CommonParams.DEBUG), rb);
-    }
-
+  /**
+   * Check if circuit breakers are tripped. Override this method in sub classes that do not want to
+   * check circuit breakers.
+   *
+   * @return true if circuit breakers are tripped, false otherwise.
+   */
+  protected boolean checkCircuitBreakers(
+      SolrQueryRequest req, SolrQueryResponse rsp, ResponseBuilder rb) {
     final RTimerTree timer = rb.isDebug() ? req.getRequestTimer() : null;
 
     final CircuitBreakerRegistry circuitBreakerRegistry = req.getCore().getCircuitBreakerRegistry();
@@ -376,9 +361,40 @@ public class SearchHandler extends RequestHandlerBase
             new SolrException(
                 SolrException.ErrorCode.SERVICE_UNAVAILABLE,
                 "Circuit Breakers tripped " + errorMessage));
-        return;
+        return true;
       }
     }
+    return false;
+  }
+
+  @Override
+  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
+    if (req.getParams().getBool(ShardParams.IS_SHARD, false)) {
+      int purpose = req.getParams().getInt(ShardParams.SHARDS_PURPOSE, 0);
+      SolrPluginUtils.forEachRequestPurpose(
+          purpose, n -> shardPurposes.computeIfAbsent(n, name -> new Counter()).inc());
+    }
+
+    List<SearchComponent> components = getComponents();
+    ResponseBuilder rb = newResponseBuilder(req, rsp, components);
+    if (rb.requestInfo != null) {
+      rb.requestInfo.setResponseBuilder(rb);
+    }
+
+    rb.isDistrib = isDistrib(req);
+    tagRequestWithRequestId(rb);
+
+    boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
+    rb.setDebug(dbg);
+    if (dbg == false) { // if it's true, we are doing everything anyway.
+      SolrPluginUtils.getDebugInterests(req.getParams().getParams(CommonParams.DEBUG), rb);
+    }
+
+    final RTimerTree timer = rb.isDebug() ? req.getRequestTimer() : null;
+
+    if (checkCircuitBreakers(req, rsp, rb)) {
+      return; // Circuit breaker tripped, return immediately
+    }
 
     // creates a ShardHandler object only if it's needed
     final ShardHandler shardHandler1 = getAndPrepShardHandler(req, rb);


[solr] 02/02: NO JIRA: add TestFieldValueFeature.testBooleanValue_docValues() case (#1881)

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 1a56cf17a6d20a424e5355877cf6e1b9242a3727
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Fri Sep 1 15:38:03 2023 +0100

    NO JIRA: add TestFieldValueFeature.testBooleanValue_docValues() case (#1881)
    
    (cherry picked from commit 09ee485d80e94594e25884b987736dce6f017006)
---
 .../apache/solr/ltr/feature/TestFieldValueFeature.java    | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/solr/modules/ltr/src/test/org/apache/solr/ltr/feature/TestFieldValueFeature.java b/solr/modules/ltr/src/test/org/apache/solr/ltr/feature/TestFieldValueFeature.java
index 8123d8ce382..5f102fb67a1 100644
--- a/solr/modules/ltr/src/test/org/apache/solr/ltr/feature/TestFieldValueFeature.java
+++ b/solr/modules/ltr/src/test/org/apache/solr/ltr/feature/TestFieldValueFeature.java
@@ -407,8 +407,21 @@ public class TestFieldValueFeature extends TestRerankBase {
 
   @Test
   public void testBooleanValue() throws Exception {
+    implTestBooleanValue("isTrendy");
+  }
+
+  @Test
+  public void testBooleanValue_docValues() throws Exception {
+    implTestBooleanValue("dvIsTrendy");
+  }
+
+  private void implTestBooleanValue(String isTrendyFieldName) throws Exception {
     final String fstore = "test_boolean_store";
-    loadFeature("trendy", FieldValueFeature.class.getName(), fstore, "{\"field\":\"isTrendy\"}");
+    loadFeature(
+        "trendy",
+        FieldValueFeature.class.getName(),
+        fstore,
+        "{\"field\":\"" + isTrendyFieldName + "\"}");
 
     loadModel(
         "trendy-model",