lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject svn commit: r1630611 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/handler/ solr/core/src/java/org/apache/solr/handler/component/ solr/core/src/java/org/apache/solr/search/ solr/core/src/java/org/apache/sol...
Date Thu, 09 Oct 2014 22:48:17 GMT
Author: anshum
Date: Thu Oct  9 22:48:16 2014
New Revision: 1630611

URL: http://svn.apache.org/r1630611
Log:
SOLR-5986: Fix tests and start returning partial results in case of ExitingReaderException
(Merge from trunk r1630583)

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/Grouping.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/MoreLikeThisHandler.java
Thu Oct  9 22:48:16 2014
@@ -54,6 +54,8 @@ import org.apache.solr.search.SolrReturn
 import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.SyntaxError;
 import org.apache.solr.util.SolrPluginUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -77,6 +79,8 @@ public class MoreLikeThisHandler extends
 {
   // Pattern is thread safe -- TODO? share this with general 'fl' param
   private static final Pattern splitList = Pattern.compile(",| ");
+
+  protected static Logger log = LoggerFactory.getLogger(MoreLikeThisHandler.class);
   
   @Override
   public void init(NamedList args) {
@@ -267,8 +271,7 @@ public class MoreLikeThisHandler extends
           }
         }
       } catch (ExitableDirectoryReader.ExitingReaderException ex) {
-        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-            "MLTHandler Request took too long during query expansion. Terminating request.");
+        log.warn( "Query: " + req.getParamString() + "; " + ex.getMessage());
       } finally {
         SolrQueryTimeoutImpl.reset();
       }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
Thu Oct  9 22:48:16 2014
@@ -244,8 +244,6 @@ public class SearchHandler extends Reque
         }
       } catch (ExitableDirectoryReader.ExitingReaderException ex) {
         log.warn( "Query: " + req.getParamString() + "; " + ex.getMessage());
-        throw new SolrException(ErrorCode.BAD_REQUEST,
-            "Request took too long during query expansion. Terminating request.");
       } finally {
         SolrQueryTimeoutImpl.reset();
       }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/Grouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/Grouping.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/Grouping.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/Grouping.java
Thu Oct  9 22:48:16 2014
@@ -28,6 +28,7 @@ import java.util.Set;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.index.ExitableDirectoryReader;
 import org.apache.lucene.queries.function.FunctionQuery;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queries.function.valuesource.QueryValueSource;
@@ -452,6 +453,9 @@ public class Grouping {
     } catch (TimeLimitingCollector.TimeExceededException x) {
       logger.warn( "Query: " + query + "; " + x.getMessage() );
       qr.setPartialResults(true);
+    } catch (ExitableDirectoryReader.ExitingReaderException e) {
+      logger.warn( "Query: " + query + "; " + e.getMessage() );
+      qr.setPartialResults(true);
     }
   }
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
Thu Oct  9 22:48:16 2014
@@ -231,7 +231,10 @@ public class SolrIndexSearcher extends I
     catch( TimeLimitingCollector.TimeExceededException x ) {
       log.warn( "Query: " + query + "; " + x.getMessage() );
       qr.setPartialResults(true);
-    }        
+    } catch ( ExitableDirectoryReader.ExitingReaderException e) {
+      log.warn("Query: " + query + "; " + e.getMessage());
+      qr.setPartialResults(true);
+    }
   }
   
   public SolrIndexSearcher(SolrCore core, String path, IndexSchema schema, SolrIndexConfig
config, String name,
@@ -1216,11 +1219,15 @@ public class SolrIndexSearcher extends I
   protected DocSet getDocSetNC(Query query, DocSet filter) throws IOException {
     DocSetCollector collector = new DocSetCollector(maxDoc()>>6, maxDoc());
 
-    if (filter==null) {
-      super.search(query,null,collector);
-    } else {
-      Filter luceneFilter = filter.getTopFilter();
-      super.search(query, luceneFilter, collector);
+    try {
+      if (filter == null) {
+        super.search(query, null, collector);
+      } else {
+        Filter luceneFilter = filter.getTopFilter();
+        super.search(query, luceneFilter, collector);
+      }
+    } catch ( ExitableDirectoryReader.ExitingReaderException e) {
+        log.warn("Query: " + query + "; " + e.getMessage());
     }
     return collector.getDocSet();
   }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/search/grouping/CommandHandler.java
Thu Oct  9 22:48:16 2014
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
+import org.apache.lucene.index.ExitableDirectoryReader;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.Filter;
@@ -230,6 +231,9 @@ public class CommandHandler {
     } catch (TimeLimitingCollector.TimeExceededException x) {
       partialResults = true;
       logger.warn( "Query: " + query + "; " + x.getMessage() );
+    } catch (ExitableDirectoryReader.ExitingReaderException e) {
+      partialResults = true;
+      logger.warn( "Query: " + query + "; " + e.getMessage() );
     }
 
     if (includeHitCount) {

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
Thu Oct  9 22:48:16 2014
@@ -503,24 +503,17 @@ public class TestDistributedSearch exten
           ShardParams.SHARDS_TOLERANT, "true");
 
       // test group query
-      // TODO: Remove this? This doesn't make any real sense now that timeAllowed might trigger
early
-      //       termination of the request during Terms enumeration/Query expansion.
-      //       During such an exit, partial results isn't supported as it wouldn't make any
sense.
-      // Increasing the timeAllowed from 1 to 100 for now.
-      //
-      // TODO: still failing in jenkins - see SOLR-5986
-      //
-      // queryPartialResults(upShards, upClients,
-      //     "q", "*:*",
-      //     "rows", 100,
-      //     "fl", "id," + i1,
-      //     "group", "true",
-      //     "group.query", t1 + ":kings OR " + t1 + ":eggs",
-      //     "group.limit", 10,
-      //     "sort", i1 + " asc, id asc",
-      //     CommonParams.TIME_ALLOWED, 100,
-      //     ShardParams.SHARDS_INFO, "true",
-      //     ShardParams.SHARDS_TOLERANT, "true");
+      queryPartialResults(upShards, upClients,
+           "q", "*:*",
+           "rows", 100,
+           "fl", "id," + i1,
+           "group", "true",
+           "group.query", t1 + ":kings OR " + t1 + ":eggs",
+           "group.limit", 10,
+           "sort", i1 + " asc, id asc",
+           CommonParams.TIME_ALLOWED, 1,
+           ShardParams.SHARDS_INFO, "true",
+           ShardParams.SHARDS_TOLERANT, "true");
 
       queryPartialResults(upShards, upClients,
           "q", "*:*",

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/CloudExitableDirectoryReaderTest.java
Thu Oct  9 22:48:16 2014
@@ -20,15 +20,11 @@ package org.apache.solr.cloud;
 
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.lucene.util.TestUtil;
-import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.solr.common.SolrException.ErrorCode;
-
 /**
 * Distributed test for {@link org.apache.lucene.index.ExitableDirectoryReader} 
 */
@@ -36,7 +32,7 @@ import static org.apache.solr.common.Sol
 public class CloudExitableDirectoryReaderTest extends AbstractFullDistribZkTestBase {
   public static Logger log = LoggerFactory.getLogger(CloudExitableDirectoryReaderTest.class);
   private static final int NUM_DOCS_PER_TYPE = 20;
-
+  
   public CloudExitableDirectoryReaderTest() {
     configString = "solrconfig-tlog-with-delayingcomponent.xml";
     schemaString = "schema.xml";
@@ -74,7 +70,7 @@ public class CloudExitableDirectoryReade
   }
 
   public void doTimeoutTests() throws Exception {
-    assertFail(params("q", "name:a*", "timeAllowed", "1"));
+    assertPartialResults(params("q", "name:a*", "timeAllowed", "1"));
 
     /*
     query rewriting for NUM_DOCS_PER_TYPE terms should take less 
@@ -86,7 +82,7 @@ public class CloudExitableDirectoryReade
     Long timeAllowed = TestUtil.nextLong(random(), fiveSeconds, Long.MAX_VALUE);
     assertSuccess(params("q", "name:a*", "timeAllowed",timeAllowed.toString()));
 
-    assertFail(params("q", "name:a*", "timeAllowed", "1"));
+    assertPartialResults(params("q", "name:a*", "timeAllowed", "1"));
 
     timeAllowed = TestUtil.nextLong(random(), fiveSeconds, Long.MAX_VALUE);
     assertSuccess(params("q", "name:b*", "timeAllowed",timeAllowed.toString()));
@@ -100,37 +96,14 @@ public class CloudExitableDirectoryReade
   /**
    * execute a request, verify that we get an expected error
    */
-  public void assertFail(ModifiableSolrParams p) throws Exception {
-    String timeoutMessage = "Request took too long during query expansion. Terminating request.";
-
-    try {
-      ignoreException(timeoutMessage);
-      queryServer(p);
-      fail("no exception matching expected: " + ErrorCode.BAD_REQUEST.code + ": " + timeoutMessage);
-    } catch (SolrServerException e) {
-      assertTrue("Exception " + e.getCause() + " is not a SolrException:\n" + prettyStackTrace(e.getCause()),
-          e.getCause() instanceof SolrException);
-      assertEquals(ErrorCode.BAD_REQUEST.code, ((SolrException)e.getCause()).code());
-      assertTrue("Expected error message substr not found: " + timeoutMessage + " <!<
" + e.getMessage(),
-                 e.getMessage().contains(timeoutMessage));
-    } finally {
-      unIgnoreException(timeoutMessage);
-    }
+  public void assertPartialResults(ModifiableSolrParams p) throws Exception {
+      QueryResponse rsp = queryServer(p);
+      assertEquals("partialResults were expected", true, rsp.getHeader().get("partialResults"));
   }
   
   public void assertSuccess(ModifiableSolrParams p) throws Exception {
     QueryResponse response = queryServer(p);
     assertEquals("Wrong #docs in response", NUM_DOCS_PER_TYPE - 1, response.getResults().getNumFound());
   }
-
-  public String prettyStackTrace(Throwable t) {
-    StringBuilder builder = new StringBuilder();
-    for (StackTraceElement elem : t.getStackTrace()) {
-      builder.append("    at ");
-      builder.append(elem.toString());
-      builder.append('\n');
-    }
-    return builder.toString();
-  }
 }
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java?rev=1630611&r1=1630610&r2=1630611&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/ExitableDirectoryReaderTest.java
Thu Oct  9 22:48:16 2014
@@ -20,6 +20,8 @@ package org.apache.solr.core;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -31,6 +33,7 @@ public class ExitableDirectoryReaderTest
   
   static int NUM_DOCS_PER_TYPE = 100;
   static final String assertionString = "//result[@numFound='"+ (NUM_DOCS_PER_TYPE - 1) +
"']";
+  static final String failureAssertionString = "/responseHeader/partialResults==true]";
 
   @BeforeClass
   public static void beforeClass() throws Exception {
@@ -57,16 +60,12 @@ public class ExitableDirectoryReaderTest
   }
 
   @Test
-  public void testPrefixQuery() {
-    assertQEx("", req("q","name:a*", "indent","true","timeAllowed","1")
-        , SolrException.ErrorCode.BAD_REQUEST
-    );
+  public void testPrefixQuery() throws Exception {
+    assertJQ(req("q", "name:a*", "indent", "true", "timeAllowed", "1"), failureAssertionString);
 
     assertQ(req("q","name:a*", "indent","true", "timeAllowed","10000"), assertionString);
 
-    assertQEx("", req("q","name:a*", "indent","true", "timeAllowed","1")
-        , SolrException.ErrorCode.BAD_REQUEST
-    );
+    assertJQ(req("q","name:a*", "indent","true", "timeAllowed","1"), failureAssertionString);
 
     assertQ(req("q","name:b*", "indent","true", "timeAllowed","10000"), assertionString);
 
@@ -78,18 +77,16 @@ public class ExitableDirectoryReaderTest
   }
   
   @Test
-  public void testQueriesOnDocsWithMultipleTerms() {
+  public void testQueriesOnDocsWithMultipleTerms() throws Exception {
     assertQ(req("q","name:dummy", "indent","true", "timeAllowed","10000"), assertionString);
 
     // This should pass even though this may take more than the 'timeAllowed' time, it doesn't
take long
     // to iterate over 1 term (dummy).
-    assertQ(req("q","name:dummy", "indent","true", "timeAllowed","10000"), assertionString);
-
-    assertQEx("", req("q","name:doc*", "indent","true", "timeAllowed","1")
-        , SolrException.ErrorCode.BAD_REQUEST
-    );
+    assertQ(req("q", "name:dummy", "indent", "true", "timeAllowed", "10000"), assertionString);
 
+    assertJQ(req("q", "name:doc*", "indent", "true", "timeAllowed", "1"), failureAssertionString);
   }
+  
 }
 
 



Mime
View raw message