Over synchronization for read-only index readers in SegmentTermDocs [LUCENE-2171]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
In SegmentTermDocs constructor (from 2.9.1)
```Java
46 protected SegmentTermDocs(SegmentReader parent) {
47 this.parent = parent;
48 this.freqStream = (IndexInput) parent.core.freqStream.clone();
49 synchronized (parent) {
50 this.deletedDocs = parent.deletedDocs;
51 }
52 this.skipInterval = parent.core.getTermsReader().getSkipInterval();
53 this.maxSkipLevels = parent.core.getTermsReader().getMaxSkipLevels();
54 }
```
The synchronization on "parent" for accessing deletedDocs is unnecessary on readonly indexes. If that access was moved into the SegmentReader then it could be protected there by default and overridden in ReadonlySegmentReader.
---
Migrated from [LUCENE-2171](https://issues.apache.org/jira/browse/LUCENE-2171) by Jayson Minard, updated May 09 2016
Contributor guide
Research direction
Start at the SegmentTermDocs constructor and trace how SegmentReader exposes deletedDocs. Compare that access with ReadonlySegmentReader, then verify that read-only index readers no longer synchronize on the parent while accessing deletedDocs and that the existing test suite still passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100