You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jérôme Etévé <je...@gmail.com> on 2008/10/24 14:21:24 UTC

Deadlock problem on searcher at warm up.

Hi everyone,

 I'm implementing a search component inherited from SearchComponent .

 This component has to build a data structure from the index. Like in
the SpellChecker, I trigger this building by giving a special argument
at query time  (from the process method) and I'm using the searcher I
get like this:

RefCounted<SolrIndexSearcher> search = rb.req.getCore()
                    .getSearcher();
...
search.decref();

I included this component at the end of the chain in my search handler.

What I'd like to do is to trigger this building for a first time at
solr startup so I don't need to artificially trigger it for a first
time.

I though it'd be ok to trigger this the very first time the process
method is called by doing something like that:

 private boolean firstTime= true ;

 public void process(ResponseBuilder rb) throws IOException {
    if ( firstTime ){
        firstTime = false ;
        buildMyStuff(rb) ;
    }
 }


The problem is that my method buildMyStuff hangs when calling
rb.req.getCore().getSearcher() ; ,
and I believe this is happening when the warm up queries are executed.

Furthermore, any regular queries on a solr instance like this would
hang and wait forever.

I there any way I can get around this problem, or is there a better
way to buildMyStuff a first time when solr is started up?

Cheers,

Jerome.

-- 
Jerome Eteve.

Chat with me live at http://www.eteve.net

jerome@eteve.net

Re: Deadlock problem on searcher at warm up.

Posted by Jérôme Etévé <je...@gmail.com>.
Great, it works now.

Thanks !

J

On Fri, Oct 24, 2008 at 4:45 PM, Yonik Seeley <yo...@apache.org> wrote:
> On Fri, Oct 24, 2008 at 8:21 AM, Jérôme Etévé <je...@gmail.com> wrote:
>> I though it'd be ok to trigger this the very first time the process
>> method is called by doing something like that:
>>
>>  private boolean firstTime= true ;
>>
>>  public void process(ResponseBuilder rb) throws IOException {
>>    if ( firstTime ){
>>        firstTime = false ;
>>        buildMyStuff(rb) ;
>>    }
>>  }
>>
>>
>> The problem is that my method buildMyStuff hangs when calling
>> rb.req.getCore().getSearcher() ; ,
>> and I believe this is happening when the warm up queries are executed.
>
> getSearcher() can wait for a searcher to be registered.
> getNewestSearcher() can be used from places like inform(), but if you
> are already in process()
> then the one you should use is the one bound to the request (the
> SolrQueryRequest object) - rb.req.getSearcher()
>
> -Yonik
>



-- 
Jerome Eteve.

Chat with me live at http://www.eteve.net

jerome@eteve.net

Re: Deadlock problem on searcher at warm up.

Posted by Yonik Seeley <yo...@apache.org>.
On Fri, Oct 24, 2008 at 8:21 AM, Jérôme Etévé <je...@gmail.com> wrote:
> I though it'd be ok to trigger this the very first time the process
> method is called by doing something like that:
>
>  private boolean firstTime= true ;
>
>  public void process(ResponseBuilder rb) throws IOException {
>    if ( firstTime ){
>        firstTime = false ;
>        buildMyStuff(rb) ;
>    }
>  }
>
>
> The problem is that my method buildMyStuff hangs when calling
> rb.req.getCore().getSearcher() ; ,
> and I believe this is happening when the warm up queries are executed.

getSearcher() can wait for a searcher to be registered.
getNewestSearcher() can be used from places like inform(), but if you
are already in process()
then the one you should use is the one bound to the request (the
SolrQueryRequest object) - rb.req.getSearcher()

-Yonik