lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romseyg...@apache.org
Subject lucene-solr:branch_7x: Avoid thread contention in LRUQueryCache test
Date Mon, 19 Feb 2018 09:50:01 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x c92458339 -> 539225eff


Avoid thread contention in LRUQueryCache test


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/539225ef
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/539225ef
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/539225ef

Branch: refs/heads/branch_7x
Commit: 539225effa70103845402f60242f1c381d4cd4b7
Parents: c924583
Author: Alan Woodward <romseygeek@apache.org>
Authored: Mon Feb 19 09:48:32 2018 +0000
Committer: Alan Woodward <romseygeek@apache.org>
Committed: Mon Feb 19 09:48:53 2018 +0000

----------------------------------------------------------------------
 .../src/test/org/apache/lucene/search/TestLRUQueryCache.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/539225ef/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
index fa9743d..57e339f 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
@@ -1486,7 +1486,11 @@ public class TestLRUQueryCache extends LuceneTestCase {
     w.addDocument(new Document());
     w.commit();
     DirectoryReader reader = DirectoryReader.open(w);
-    IndexSearcher searcher = newSearcher(reader);
+
+    // Don't use newSearcher(), because that will sometimes use an ExecutorService, and
+    // we need to be single threaded to ensure that LRUQueryCache doesn't skip the cache
+    // due to thread contention
+    IndexSearcher searcher = new AssertingIndexSearcher(random(), reader);
     searcher.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
 
     LRUQueryCache cache = new LRUQueryCache(1, 10000, context -> true);


Mime
View raw message