LUCENE-10134: Move initialization of liveDocs bits outside the constructor to avoid AssertionError (#345)

Co-authored-by: Ankur Goel <goankur@amazon.com>
This commit is contained in:
goankur 2021-09-30 23:57:11 -07:00 committed by GitHub
parent 4c97b9e3f2
commit cb366d04d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));