You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Cyrille Roy (JIRA)" <ji...@apache.org> on 2014/11/03 23:57:39 UTC

[jira] [Comment Edited] (SOLR-2927) SolrIndexSearcher's register do not match close and SolrCore's closeSearcher

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

Cyrille Roy edited comment on SOLR-2927 at 11/3/14 10:57 PM:
-------------------------------------------------------------

hi [~shalinmangar],
this is great news.
I have some of the mbeans leaking in the attached mbean-jira-leaked.png that I have attached.
Also, I have been able to fix the leak with the SOLR-2927.patch attached.
Do you still see the leaking mbeans after applying the patch ?

The issue is a race condition.
when opening a core, solr is preventing searchers from firing by starting a thread that blocks in a single threaded executor at line 783:
searcherExecutor.submit(new Callable() {
@Override
public Object call() throws Exception {
latch.await();
return null;
}
});

Other events are queued using the thread executor line 864 when calling the getSearcher(false, false, null, true) method.
getSearcher calls registerSearcher which calls register which registers mbeans using the getInfoRegistry().put(key, value) method

on exception, the latch is released, so searcher threads can fire and write things in the mbean using the infoRegistry map.
} catch (Throwable e) {
latch.countDown();//release the latch, otherwise we block trying to do the close. This should be fine, since counting down on a latch of 0 is still fine
//close down the searcher and any other resources, if it exists, as this is not recoverable
close();

And indeed it is what is happening in close()

we clean the mbean at line 990
try {
infoRegistry.clear();
} catch (Throwable e) {
SolrException.log(log, e);
}

and then wait for searcher thread completion at line 1070
try {
ExecutorUtil.shutdownAndAwaitTermination(searcherExecutor);
} catch (Throwable e) {
SolrException.log(log, e);
}

putting this before the registry clean actually solves the issue.


was (Author: croy):
hi [~shalinmangar],
this is great news.
I have some of the mbeans leaking in the attached mbean-jira-leaked.png that I have attached.
Also, I have been able to fix the leak with the SOLR-2927.patch attached.
Do you still see the leaking mbeans after applying the patch ?

The issue is a race condition.
when opening a core, solr is preventing searchers from firing by starting a thread that blocks in a single threaded executor at line 783:
searcherExecutor.submit(new Callable() {
@Override
public Object call() throws Exception {
latch.await();
return null;
}
});

Other events are queued using the thread executor line 864 when calling the getSearcher(false, false, null, true) method

on exception, the latch is released, so searcher threads can fire and write things in the mbean using the infoRegistry map.
} catch (Throwable e) {
latch.countDown();//release the latch, otherwise we block trying to do the close. This should be fine, since counting down on a latch of 0 is still fine
//close down the searcher and any other resources, if it exists, as this is not recoverable
close();

And indeed it is what is happening in close()

we clean the mbean at line 990
try {
infoRegistry.clear();
} catch (Throwable e) {
SolrException.log(log, e);
}

and then wait for searcher thread completion at line 1070
try {
ExecutorUtil.shutdownAndAwaitTermination(searcherExecutor);
} catch (Throwable e) {
SolrException.log(log, e);
}

putting this before the registry clean actually solves the issue.

> SolrIndexSearcher's register do not match close and SolrCore's closeSearcher
> ----------------------------------------------------------------------------
>
>                 Key: SOLR-2927
>                 URL: https://issues.apache.org/jira/browse/SOLR-2927
>             Project: Solr
>          Issue Type: Bug
>          Components: search
>    Affects Versions: 4.0-ALPHA
>         Environment: JDK1.6/CentOS
>            Reporter: tom liu
>            Assignee: Shalin Shekhar Mangar
>             Fix For: 4.9, Trunk
>
>         Attachments: SOLR-2927.patch, mbean-leak-jira.png
>
>
> # SolrIndexSearcher's register method put the name of searcher, but SolrCore's closeSearcher method remove name of currentSearcher on infoRegistry.
> # SolrIndexSearcher's register method put the name of cache, but SolrIndexSearcher's close do not remove the name of cache.
> so, there maybe lost some memory leak.



--
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