You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mihai Caraman <ca...@gmail.com> on 2011/09/29 17:41:56 UTC
TaxWriter leakage?
There may be some likage while using threadedIndexWriter...
The app start as a listener servlet in tomcat6
First start, all ok.
First close, none of these lines appear:
*INFO: A valid shutdown command was received via the shutdown port. Stopping
the Server instance.
Sep 29, 2011 3:28:34 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-80"]
Sep 29, 2011 3:28:35 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Sep 29, 2011 3:28:36 PM org.apache.catalina.core.StandardService
stopInternal
INFO: Stopping service Catalina
**Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-80"]
Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-80"]
Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]*
Second start:
Exception in thread "pool-1-thread-3" java.lang.NullPointerException
at
org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.getParent(LuceneTaxonomyWriter.java:724)
at
org.apache.lucene.facet.index.streaming.CategoryParentsStream.incrementToken(CategoryParentsStream.java:106)
at
org.apache.lucene.facet.index.streaming.CountingListTokenizer.incrementToken(CountingListTokenizer.java:63)
at
org.apache.lucene.facet.index.streaming.CategoryTokenizer.incrementToken(CategoryTokenizer.java:48)
at
org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:185)
at
org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
at
org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
at
org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2067)
at
org.myapp.search.CustomLucene.ThreadedIndexWriter.access$1(ThreadedIndexWriter.java:1)
at
org.myapp.search.CustomLucene.ThreadedIndexWriter$Job.run(ThreadedIndexWriter.java:39)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Re: TaxWriter leakage?
Posted by Mihai Caraman <ca...@gmail.com>.
2011/10/4 Doron Cohen <cd...@gmail.com>
> LUCENE-3484 is resolved.
> Mihai, could you give it a try and see if this solves the NPE problem in
> your setup?
>
As Jim Carrey whould say: Like a glove!
Re: TaxWriter leakage?
Posted by Doron Cohen <cd...@gmail.com>.
LUCENE-3484 is resolved.
Mihai, could you give it a try and see if this solves the NPE problem in
your setup?
You would need to download a nightly build that contains the fix - see the
issue for revision numbers...
On Tue, Oct 4, 2011 at 7:51 PM, Mihai Caraman <ca...@gmail.com>wrote:
> > (org.myapp.search.CustomLucene.ThreadedIndexWriter).
> >
> it's just the threaded example from Lucene In Action SE(Listing 10.1)
>
Oh ok, thanks.
Doron
Re: TaxWriter leakage?
Posted by Mihai Caraman <ca...@gmail.com>.
> (org.myapp.search.CustomLucene.ThreadedIndexWriter).
>
> it's just the threaded example from Lucene In Action SE(Listing 10.1)
I opened https://issues.apache.org/jira/browse/LUCENE-3484 for this and will
> fix this soon.
> Patch in that issue shows how to reproduce this error.
>
> Thanks for reporting this!
>
Nop, thank you!
Re: TaxWriter leakage?
Posted by Doron Cohen <cd...@gmail.com>.
On Tue, Oct 4, 2011 at 11:29 AM, Mihai Caraman <ca...@gmail.com>wrote:
> I also think that there is nothing special in the second restart, except
>
> > that that by that time there were other servlets up (?) which were able
> to
> > trigger simultaneous AddDoc requests, exposing this bug...
> >
> > Makes sense?
> >
>
> It does. Can those two Ts be from the threadedindexwriter?
>
I assume so, though I am not sure what is in that threaded index writer as
it seems part of your app
(org.myapp.search.CustomLucene.ThreadedIndexWriter).
I opened https://issues.apache.org/jira/browse/LUCENE-3484 for this and will
fix this soon.
Patch in that issue shows how to reproduce this error.
Thanks for reporting this!
Re: TaxWriter leakage?
Posted by Mihai Caraman <ca...@gmail.com>.
I also think that there is nothing special in the second restart, except
> that that by that time there were other servlets up (?) which were able to
> trigger simultaneous AddDoc requests, exposing this bug...
>
> Makes sense?
>
It does. Can those two Ts be from the threadedindexwriter?
Re: TaxWriter leakage?
Posted by Doron Cohen <cd...@gmail.com>.
Looking into this with Shai I think we see how this can happen, in this code
of LTW:
private ParentArray getParentArray() throws IOException {
if (parentArray==null) { // [1]
if (reader == null) {
reader = openReader();
}
parentArray = new ParentArray(); // [2]
parentArray.refresh(reader); // [3]
}
return parentArray;
}
The method getParentArray() is not synchronized, and hence if there are two
calls from two different threads T1, T2, (both adding documents or such):
* T1 gets to point [1] above and see null
* T1 gets to point [2] and assigns a fresh parentArray
* Context switch, T2 gets to "drive"
* T2 gets to point [1], sees a non null parent array, and returns it
immediately
Since T1 did not yet get to point [3], the parent array is not yet
initialized, hence the NPE that T2 gets when accessing the internal array of
the parent array.
If this is the case then it is surprising that this error did not yet
happen.
Need to open a JIRA issue for this and add some synchronization.
Best if we can create this is in a standalone test.
I also think that there is nothing special in the second restart, except
that that by that time there were other servlets up (?) which were able to
trigger simultaneous AddDoc requests, exposing this bug...
Makes sense?
On Tue, Oct 4, 2011 at 6:58 AM, Shai Erera <se...@gmail.com> wrote:
> The source code is available and you can check it out from
>
> http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/lucene/contrib/facet
> .
> After you modify the code, you can call "ant jar" (if you have Ant
> installed) and it will generate the facet .jar for you. If it doesn't work
> for you, let me know and I'll generate one for you.
>
> Shai
>
> On Mon, Oct 3, 2011 at 7:21 PM, Mihai Caraman <caraman.mihai@gmail.com
> >wrote:
>
> > Uwe :
> >
> > > Maybe another Java7 bug? Are you using Java 7?
> > >
> > Nop, java 1.6
> >
> > Shai
> > > return getParentArray().getArray()[ordinal];
> > >
> > Can you give me a lucene jar with print outs for when it throws this NPE?
> >
> > ...How is using ThreadedIndexWriter related
> > >
> > When I remove the Threaded version, it doesn't give me any problems.
> > Otherwise, when i first deploy the jar, (and maybe because it gets a bit
> > overwhelmed with accumulated data(from a distributed queue-Kestrel) it
> > throws that nasty error for every Indexing thread, in my case for all 6
> of.
> > After that if i restart the server, no more exception.
> >
> > I tried to reproduce the error, with only the Readers and writers and
> with
> > some bogus data, but it didn't throw anything.
> >
>
Re: TaxWriter leakage?
Posted by Shai Erera <se...@gmail.com>.
The source code is available and you can check it out from
http://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x/lucene/contrib/facet.
After you modify the code, you can call "ant jar" (if you have Ant
installed) and it will generate the facet .jar for you. If it doesn't work
for you, let me know and I'll generate one for you.
Shai
On Mon, Oct 3, 2011 at 7:21 PM, Mihai Caraman <ca...@gmail.com>wrote:
> Uwe :
>
> > Maybe another Java7 bug? Are you using Java 7?
> >
> Nop, java 1.6
>
> Shai
> > return getParentArray().getArray()[ordinal];
> >
> Can you give me a lucene jar with print outs for when it throws this NPE?
>
> ...How is using ThreadedIndexWriter related
> >
> When I remove the Threaded version, it doesn't give me any problems.
> Otherwise, when i first deploy the jar, (and maybe because it gets a bit
> overwhelmed with accumulated data(from a distributed queue-Kestrel) it
> throws that nasty error for every Indexing thread, in my case for all 6 of.
> After that if i restart the server, no more exception.
>
> I tried to reproduce the error, with only the Readers and writers and with
> some bogus data, but it didn't throw anything.
>
Re: TaxWriter leakage?
Posted by Mihai Caraman <ca...@gmail.com>.
Uwe :
> Maybe another Java7 bug? Are you using Java 7?
>
Nop, java 1.6
Shai
> return getParentArray().getArray()[ordinal];
>
Can you give me a lucene jar with print outs for when it throws this NPE?
...How is using ThreadedIndexWriter related
>
When I remove the Threaded version, it doesn't give me any problems.
Otherwise, when i first deploy the jar, (and maybe because it gets a bit
overwhelmed with accumulated data(from a distributed queue-Kestrel) it
throws that nasty error for every Indexing thread, in my case for all 6 of.
After that if i restart the server, no more exception.
I tried to reproduce the error, with only the Readers and writers and with
some bogus data, but it didn't throw anything.
Re: TaxWriter leakage?
Posted by Uwe Schindler <uw...@thetaphi.de>.
Maybe another Java7 bug? Are you using Java 7?
--
Uwe Schindler
H.-H.-Meier-Allee 63, 28213 Bremen
http://www.thetaphi.de
Shai Erera <se...@gmail.com> schrieb:
That's weird. The line that throws the NPE seems like it ... well, cannot
throw an NPE :).
LuceneTaxonomyWriter, line 724:
return getParentArray().getArray()[ordinal];
getParentArray() never returns null, so it cannot be from there.
ParentArray.getArray() cannot return null, as its internal array is
initialized by LuceneTaxonomyWriter.getParentArray() (see lines 712-713), so
that's really odd.
But perhaps we're looking in the wrong place. Can you please describe what
are the steps that you perform, and how is using ThreadedIndexWriter
related?
Shai
On Thu, Sep 29, 2011 at 7:22 PM, Mihai Caraman <ca...@gmail.com>wrote:
> Hmm.. if i leave it a couple of minutes before restarting, it doesn't log
> the proper shutdown steps, but it does restart correctly.
>
> 2011/9/29 Mihai Caraman <ca...@gmail.com>
>
> > There may be some likage while using threadedIndexWriter...
> >
> > The app start as a listener servlet in tomcat6
> > First start, all ok.
> > First close, none of these lines appear:
> > *INFO: A valid shutdown command was received via the shutdown port.
> > Stopping the Server instance.
> > Sep 29, 2011 3:28:34 PM org.apache.coyote.AbstractProtocol pause
> > INFO: Pausing ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:35 PM org.apache.coyote.AbstractProtocol pause
> > INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
> > Sep 29, 2011 3:28:36 PM org.apache.catalina.core.StandardService
> > stopInternal
> > INFO: Stopping service Catalina
> >
> > **Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> > INFO: Stopping ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> > INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> > INFO: Destroying ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> > INFO: Destroying ProtocolHandler ["ajp-bio-8009"]*
> >
> > Second start:
> > Exception in thread "pool-1-thread-3" java.lang.NullPointerException
> > at
> >
> org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.getParent(LuceneTaxonomyWriter.java:724)
> > at
> >
> org.apache.lucene.facet.index.streaming.CategoryParentsStream.incrementToken(CategoryParentsStream.java:106)
> > at
> >
> org.apache.lucene.facet.index.streaming.CountingListTokenizer.incrementToken(CountingListTokenizer.java:63)
> > at
> >
> org.apache.lucene.facet.index.streaming.CategoryTokenizer.incrementToken(CategoryTokenizer.java:48)
> > at
> >
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:185)
> > at
> >
> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
> > at
> >
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
> > at
> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2067)
> > at
> >
> org.myapp.search.CustomLucene.ThreadedIndexWriter.access$1(ThreadedIndexWriter.java:1)
> > at
> >
> org.myapp.search.CustomLucene.ThreadedIndexWriter$Job.run(ThreadedIndexWriter.java:39)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> > at java.lang.Thread.run(Thread.java:662)
> >
> >
> >
>
Re: TaxWriter leakage?
Posted by Shai Erera <se...@gmail.com>.
That's weird. The line that throws the NPE seems like it ... well, cannot
throw an NPE :).
LuceneTaxonomyWriter, line 724:
return getParentArray().getArray()[ordinal];
getParentArray() never returns null, so it cannot be from there.
ParentArray.getArray() cannot return null, as its internal array is
initialized by LuceneTaxonomyWriter.getParentArray() (see lines 712-713), so
that's really odd.
But perhaps we're looking in the wrong place. Can you please describe what
are the steps that you perform, and how is using ThreadedIndexWriter
related?
Shai
On Thu, Sep 29, 2011 at 7:22 PM, Mihai Caraman <ca...@gmail.com>wrote:
> Hmm.. if i leave it a couple of minutes before restarting, it doesn't log
> the proper shutdown steps, but it does restart correctly.
>
> 2011/9/29 Mihai Caraman <ca...@gmail.com>
>
> > There may be some likage while using threadedIndexWriter...
> >
> > The app start as a listener servlet in tomcat6
> > First start, all ok.
> > First close, none of these lines appear:
> > *INFO: A valid shutdown command was received via the shutdown port.
> > Stopping the Server instance.
> > Sep 29, 2011 3:28:34 PM org.apache.coyote.AbstractProtocol pause
> > INFO: Pausing ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:35 PM org.apache.coyote.AbstractProtocol pause
> > INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
> > Sep 29, 2011 3:28:36 PM org.apache.catalina.core.StandardService
> > stopInternal
> > INFO: Stopping service Catalina
> >
> > **Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> > INFO: Stopping ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> > INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> > INFO: Destroying ProtocolHandler ["http-bio-80"]
> > Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> > INFO: Destroying ProtocolHandler ["ajp-bio-8009"]*
> >
> > Second start:
> > Exception in thread "pool-1-thread-3" java.lang.NullPointerException
> > at
> >
> org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.getParent(LuceneTaxonomyWriter.java:724)
> > at
> >
> org.apache.lucene.facet.index.streaming.CategoryParentsStream.incrementToken(CategoryParentsStream.java:106)
> > at
> >
> org.apache.lucene.facet.index.streaming.CountingListTokenizer.incrementToken(CountingListTokenizer.java:63)
> > at
> >
> org.apache.lucene.facet.index.streaming.CategoryTokenizer.incrementToken(CategoryTokenizer.java:48)
> > at
> >
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:185)
> > at
> >
> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
> > at
> >
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
> > at
> > org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2067)
> > at
> >
> org.myapp.search.CustomLucene.ThreadedIndexWriter.access$1(ThreadedIndexWriter.java:1)
> > at
> >
> org.myapp.search.CustomLucene.ThreadedIndexWriter$Job.run(ThreadedIndexWriter.java:39)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> > at java.lang.Thread.run(Thread.java:662)
> >
> >
> >
>
Re: TaxWriter leakage?
Posted by Mihai Caraman <ca...@gmail.com>.
Hmm.. if i leave it a couple of minutes before restarting, it doesn't log
the proper shutdown steps, but it does restart correctly.
2011/9/29 Mihai Caraman <ca...@gmail.com>
> There may be some likage while using threadedIndexWriter...
>
> The app start as a listener servlet in tomcat6
> First start, all ok.
> First close, none of these lines appear:
> *INFO: A valid shutdown command was received via the shutdown port.
> Stopping the Server instance.
> Sep 29, 2011 3:28:34 PM org.apache.coyote.AbstractProtocol pause
> INFO: Pausing ProtocolHandler ["http-bio-80"]
> Sep 29, 2011 3:28:35 PM org.apache.coyote.AbstractProtocol pause
> INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
> Sep 29, 2011 3:28:36 PM org.apache.catalina.core.StandardService
> stopInternal
> INFO: Stopping service Catalina
>
> **Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> INFO: Stopping ProtocolHandler ["http-bio-80"]
> Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol stop
> INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
> Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> INFO: Destroying ProtocolHandler ["http-bio-80"]
> Sep 29, 2011 3:28:45 PM org.apache.coyote.AbstractProtocol destroy
> INFO: Destroying ProtocolHandler ["ajp-bio-8009"]*
>
> Second start:
> Exception in thread "pool-1-thread-3" java.lang.NullPointerException
> at
> org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.getParent(LuceneTaxonomyWriter.java:724)
> at
> org.apache.lucene.facet.index.streaming.CategoryParentsStream.incrementToken(CategoryParentsStream.java:106)
> at
> org.apache.lucene.facet.index.streaming.CountingListTokenizer.incrementToken(CountingListTokenizer.java:63)
> at
> org.apache.lucene.facet.index.streaming.CategoryTokenizer.incrementToken(CategoryTokenizer.java:48)
> at
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:185)
> at
> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
> at
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
> at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2067)
> at
> org.myapp.search.CustomLucene.ThreadedIndexWriter.access$1(ThreadedIndexWriter.java:1)
> at
> org.myapp.search.CustomLucene.ThreadedIndexWriter$Job.run(ThreadedIndexWriter.java:39)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
>
>
>