lucene-commits mailing list archives

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


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/a2fdbc93
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a2fdbc93
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a2fdbc93

Branch: refs/heads/master
Commit: a2fdbc93534263299f055a9e344c49bf29aebdf5
Parents: 34d3282
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:50:12 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/a2fdbc93/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 f6b1c73..eac8b4e 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
@@ -1475,7 +1475,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, Float.POSITIVE_INFINITY);


Mime
View raw message