lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <cdor...@gmail.com>
Subject Re: TaxWriter leakage?
Date Tue, 04 Oct 2011 08:17:40 GMT
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 <serera@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.
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message