diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 2b389e54a7..6faa702d77 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ - 3.0.54011 - 3.0.54011.0 + 3.0.54012 + 3.0.54012.0 latest embedded diff --git a/src/Lucene.Net/Index/SegmentReader.cs b/src/Lucene.Net/Index/SegmentReader.cs index 927f424636..c8dd5b1522 100644 --- a/src/Lucene.Net/Index/SegmentReader.cs +++ b/src/Lucene.Net/Index/SegmentReader.cs @@ -191,10 +191,16 @@ internal Directory GetCFSReader() return cfsReader; } } - + internal TermInfosReader GetTermsReader() - { - lock (this) + { + // This is initialized in the constructor. + // The only time it isn't initialized is when termsIndexDivisor equals -1, which we don't use. + var reader = tis; + if (reader != null) + return reader; + + lock (this) { if (tis != null) { @@ -208,11 +214,9 @@ internal TermInfosReader GetTermsReader() } internal bool TermsIndexIsLoaded() - { - lock (this) - { - return tis != null; - } + { + // If this is null, we call LoadTermsIndex, which uses a lock. + return tis != null; } // NOTE: only called from IndexWriter when a near @@ -220,8 +224,11 @@ internal bool TermsIndexIsLoaded() // sharing a segment that's still being merged. This // method is not fully thread safe, and relies on the // synchronization in IndexWriter - internal void LoadTermsIndex(SegmentInfo si, int termsIndexDivisor, IState state) - { + internal void LoadTermsIndex(SegmentInfo si, int termsIndexDivisor, IState state) + { + if (tis != null) + return; + lock (this) { if (tis == null) @@ -310,7 +317,10 @@ internal void DecRef() } internal void OpenDocStores(SegmentInfo si, IState state) - { + { + if (fieldsReaderOrig != null) + return; + lock (this) {