You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/10/01 06:57:16 UTC

[lucene] branch main updated: LUCENE-10134: Move initialization of liveDocs bits outside the constructor to avoid AssertionError (#345)

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

dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new cb366d0  LUCENE-10134: Move initialization of liveDocs bits outside the constructor to avoid AssertionError (#345)
cb366d0 is described below

commit cb366d04d4a611faf90b36e49aa4bd9b48a6e83d
Author: goankur <47...@users.noreply.github.com>
AuthorDate: Thu Sep 30 23:57:11 2021 -0700

    LUCENE-10134: Move initialization of liveDocs bits outside the constructor to avoid AssertionError (#345)
    
    Co-authored-by: Ankur Goel <go...@amazon.com>
---
 .../facet/sortedset/ConcurrentSortedSetDocValuesFacetCounts.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lucene/facet/src/java/org/apache/lucene/facet/sortedset/ConcurrentSortedSetDocValuesFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/sortedset/ConcurrentSortedSetDocValuesFacetCounts.java
index 09b305b..1ee7863 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/sortedset/ConcurrentSortedSetDocValuesFacetCounts.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/sortedset/ConcurrentSortedSetDocValuesFacetCounts.java
@@ -161,7 +161,6 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends Facets {
     final MatchingDocs hits;
     final OrdinalMap ordinalMap;
     final int segOrd;
-    final Bits liveDocs;
 
     public CountOneSegment(
         LeafReader leafReader, MatchingDocs hits, OrdinalMap ordinalMap, int segOrd) {
@@ -170,7 +169,6 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends Facets {
       this.hits = hits;
       this.ordinalMap = ordinalMap;
       this.segOrd = segOrd;
-      this.liveDocs = leafReader.getLiveDocs();
     }
 
     @Override
@@ -198,6 +196,10 @@ public class ConcurrentSortedSetDocValuesFacetCounts extends Facets {
       DocIdSetIterator it;
       if (hits == null) {
         // count all
+        // Initializing liveDocs bits in the constructor leads to a situation where liveDocs bits
+        // get initialized in the calling thread but get used in a different thread leading to an
+        // AssertionError. See LUCENE-10134
+        final Bits liveDocs = leafReader.getLiveDocs();
         it = (liveDocs != null) ? FacetUtils.liveDocsDISI(valuesIt, liveDocs) : valuesIt;
       } else {
         it = ConjunctionUtils.intersectIterators(Arrays.asList(hits.bits.iterator(), valuesIt));