You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Michael Sokolov (Jira)" <ji...@apache.org> on 2022/04/07 22:43:00 UTC

[jira] [Commented] (LUCENE-10292) AnalyzingInfixSuggester thread safety: lookup() fails during (re)build()

    [ https://issues.apache.org/jira/browse/LUCENE-10292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519219#comment-17519219 ] 

Michael Sokolov commented on LUCENE-10292:
------------------------------------------

It's surprising it took so long for someone to stumble over this. Maybe because most (as I used to do) rebuild their suggesters off line as part of a batch build process? Anyway I looked over the patch and didn't see any problem except a typo in tests "testDurringReBuild" should probably be "testDuringRebuild"? Thanks for the nice tests!

> AnalyzingInfixSuggester thread safety: lookup() fails during (re)build()
> ------------------------------------------------------------------------
>
>                 Key: LUCENE-10292
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10292
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Chris M. Hostetter
>            Assignee: Chris M. Hostetter
>            Priority: Major
>         Attachments: LUCENE-10292-1.patch, LUCENE-10292-2.patch, LUCENE-10292.patch
>
>
> I'm filing this based on anecdotal information from a Solr user w/o experiencing it first hand (and I don't have a test case to demonstrate it) but based on a reading of the code the underlying problem seems self evident...
> With all other Lookup implementations I've examined, it is possible to call {{lookup()}} regardless of whether another thread is concurrently calling {{build()}} – in all cases I've seen, it is even possible to call {{lookup()}} even if {{build()}} has never been called: the result is just an "empty" {{List<LookupResult>}} 
> Typically this is works because the {{build()}} method uses temporary datastructures until it's "build logic" is complete, at which point it atomically replaces the datastructures used by the {{lookup()}} method.   In the case of {{AnalyzingInfixSuggester}} however, the {{build()}} method starts by closing & null'ing out the {{protected SearcherManager searcherMgr}} (which it only populates again once it's completed building up it's index) and then the lookup method starts with...
> {code:java}
>     if (searcherMgr == null) {
>       throw new IllegalStateException("suggester was not built");
>     }
> {code}
> ... meaning it is unsafe to call {{AnalyzingInfixSuggester.lookup()}} in any situation where another thread may be calling {{AnalyzingInfixSuggester.build()}}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org