sonatype-lift[bot] commented on a change in pull request #592: URL: https://github.com/apache/solr/pull/592#discussion_r800033599
########## File path: solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java ########## @@ -865,9 +936,26 @@ public BitDocSet getLiveDocSet() throws IOException { // Going through the filter cache will provide thread safety here if we only had getLiveDocs, // but the addition of setLiveDocs means we needed to add volatile to "liveDocs". BitDocSet docs = liveDocs; - if (docs == null) { - //note: maybe should instead calc manually by segment, using FixedBitSet.copyOf(segLiveDocs); avoid filter cache? - liveDocs = docs = getDocSetBits(matchAllDocsQuery); + if (docs != null) { + matchAllDocsCacheHitCount.incrementAndGet(); + } else { + synchronized (matchAllDocsCacheComputationTracker) { + if (liveDocsFuture != null) { + // use future if it already exists + assert matchAllDocsCacheComputationTracker.incrementAndGet() > 0; + } else { + // otherwise create the initial/only future, and run it inline + assert matchAllDocsCacheComputationTracker.getAndSet(0) == Long.MIN_VALUE; + liveDocsFuture = new FutureTask<>(this::computeLiveDocs); + liveDocsFuture.run(); // first caller will block execution here + } + } + try { + docs = liveDocsFuture.get(); // subsequent callers block here, waiting for initial/only execution to complete Review comment: *THREAD_SAFETY_VIOLATION:* Read/Write race. Non-private method `SolrIndexSearcher.getLiveDocSet()` reads without synchronization from `this.liveDocsFuture`. Potentially races with write in method `SolrIndexSearcher.getDocSetNC(...)`. Reporting because this access may occur on a background thread. (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`) -- 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-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org