lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chengdu Huang <chengdu.hu...@patterninsight.com>
Subject Re: deadlock in indexing
Date Tue, 28 Jul 2009 18:20:24 GMT
Thanks, Mike.

Can you elaborate a bit more on why this would cause deadlock?  Thanks.

Chengdu

On Tue, Jul 28, 2009 at 10:48 AM, Michael
McCandless<lucene@mikemccandless.com> wrote:
> This can in fact result in deadlock; you should sync on your own Object instead.
>
> Mike
>
> On Tue, Jul 28, 2009 at 12:27 AM, Chengdu
> Huang<chengdu.huang@patterninsight.com> wrote:
>> Hi,
>>
>> I have an application in which documents are added upon receiving a
>> user request and a background thread is needed to remove old
>> documents.  I have an IndexWriter opened on a Directory that adds
>> documents and commits but never closes.  The background thread that
>> removes documents uses the same instance of IndexWriter.  So the code
>> looks like
>>
>> // Thread to add document:
>> synchronized(writer) {
>>  try {
>>    Document doc = new Document();
>>    doc.add();
>>    ...
>>    writer.commit();
>>  } catch (Exception e) {
>>    writer.rollback();
>>  }
>> }
>>
>> Now looks like I run into some kind of deadlock here even *WITHOUT*
>> the background thread of removing documents.  The symptom is that the
>> whole java process is on sleeping state and jstack shows that the
>> thread to add document is blocked on waiting an object.  Unfortunately
>> I'm unable to reproduce this in unittests.
>>
>> My guess is that the outer synchronized(writer) {} block is causing
>> the problem, but can't figure out why.  Any idea?
>>
>> Chengdu
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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


Mime
View raw message