You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Lukhnos Liu (JIRA)" <ji...@apache.org> on 2016/03/07 06:17:40 UTC

[jira] [Closed] (LUCENE-6811) AnalyzingInfixSuggester cannot be used in more than one thread

     [ https://issues.apache.org/jira/browse/LUCENE-6811?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukhnos Liu closed LUCENE-6811.
-------------------------------
    Resolution: Won't Fix

According to Varun's comment the issue can be addressed by reusing the thread-safe suggester.


> AnalyzingInfixSuggester cannot be used in more than one thread
> --------------------------------------------------------------
>
>                 Key: LUCENE-6811
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6811
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/other
>    Affects Versions: 5.3
>            Reporter: Lukhnos Liu
>              Labels: suggester
>
> Currently AnalyzingInfixSuggester always opens an index writer, even if the suggester will be used entirely in read-only mode. I was trying to serve suggestions out of the same index in a multithreaded setup, but I could only create one suggester per index per process because of this design.
> I've created a GitHub project to demonstrate the bug: [https://github.com/lukhnos/lucene-analyzing-infix-suggester-bug]
> To run the demo:
> {code}
> ./gradlew build
> java -jar build/libs/lucene-analyzing-infix-suggester-bug.jar
> {code}
> The exception reads:
> {code}
> Exception in thread "Thread-1" java.lang.RuntimeException: org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine: <INDEX DIR>/write.lock
>     at org.lukhnos.lucenestudy.AnalyzingInfixSuggesterBug$1SuggestReader.run(AnalyzingInfixSuggesterBug.java:65)
>     at java.lang.Thread.run(Thread.java:745)
> Caused by: org.apache.lucene.store.LockObtainFailedException: Lock held by this virtual machine: <INDEX DIR>/write.lock
>     at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:127)
>     at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41)
>     at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45)
>     at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:775)
>     at org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester.<init>(AnalyzingInfixSuggester.java:251)
>     at org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester.<init>(AnalyzingInfixSuggester.java:163)
>     at org.lukhnos.lucenestudy.AnalyzingInfixSuggesterBug$1SuggestReader.run(AnalyzingInfixSuggesterBug.java:51)
>     ... 1 more
> {code}
> To work around this problem, I'm currently using my own modified "read only" AnalyzingInfixSuggester, in which I commented out the index writer creation code in the constructor. Then, in the lookup method, I also commented out the part where we get an EarlyTerminatingSortingCollector out of the index writer, so that only a TopFieldCollector is used.
> I was wondering if a read-only mode can be added to AnalyzingInfixSuggester, or at least the contract of getIndexWriterConfig can be changed -- since one will have to subclass to use a different index writer config anyway -- such that if one returns null in getIndexWriterConfig, the suggester will operate in read-only mode, and so no index writer is created. Of course an error will have to be thrown if any build or update methods are called in such mode.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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