You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Stefan Heidrich (JIRA)" <ji...@apache.org> on 2009/03/10 09:52:50 UTC

[jira] Created: (LUCENE-1555) Deadlock while optimize

Deadlock while optimize
-----------------------

                 Key: LUCENE-1555
                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 2.4
         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
            Reporter: Stefan Heidrich


Sometimes after starting the thread with the indexer, the thread will hang in the following threads.

Thread [Lucene Merge Thread #0] (Ausgesetzt)	
	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
	ConcurrentMergeScheduler$MergeThread.run() Line: 260	

Thread [Indexer] (Ausgesetzt)	
	Object.wait(long) Line: not available [native Methode]	
	IndexWriter.doWait() Line: 4491	
	IndexWriter.optimize(int, boolean) Line: 2268	
	IndexWriter.optimize(boolean) Line: 2203	
	IndexWriter.optimize() Line: 2183	
	Indexer.run() Line: 263	


If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Re: [Mira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by pd...@yahoo.com.
-----Original Message-----
From: "Michael McCandless (JIRA)" <ji...@apache.org>

Date: Wed, 11 Mar 2009 05:56:50 
To: <ja...@lucene.apache.org>
Subject: [jira] Commented: (LUCENE-1555) Deadlock while optimize



    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680864#action_12680864 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------

bq. First of all, I could solve the problem by using IndexWriter.close(true) instead of IndexWriter.close().

Did you mean false instead of true?  (waitForMerges=true is what
close() does by default).

This (false) is dangerous to do, always, since it could result in merge
starvation whereby long-running merges never have a chance to
complete (I just updated 2.9 javadocs to state this).

{quote}
The indexer thread will index new data periodically. But if the indexer threat is started, it will perform an optimize as well. So it could happen that

((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

and

indexWriter = new IndexWriter(indexDirectory, analyser , false, MaxFieldLength.UNLIMITED);
indexWriter.optimize(MAX_MERGED_FILES);
((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

will be executed one after another. With close() this could result in a lock.
{quote}

I don't really follow what you're saying here.  Are you saying calling
ConcurrentMergeScheduler.sync() leads to the deadlock, or, prevents
it?

By indexer thread, do you mean you are launching your own threads to
do indexing, or are you talking about ConcurrentMergeScheduler's
threads?

Are you doing any external synchronization on IndexWriter yourself?

Are you calling IndexWriter.close() from multiple threads?

Can you post every thread in your thread dump?  (Or, is it really the
case that you only have 2 threads?).

bq. I've only changed the maxFieldLength of the writer to 50000.

OK that's fine.


> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Stefan Heidrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680795#action_12680795 ] 

Stefan Heidrich commented on LUCENE-1555:
-----------------------------------------

It seems that the IndexWriter tries to lock two times. 

"Lucene Merge Thread #0" daemon prio=1 tid=0x08a7d3c8 nid=0x229a waiting for monitor entry [0x8ae78000..0x8ae78dc0]
	at org.apache.lucene.index.IndexWriter.commitMerge(IndexWriter.java:3758)
	- waiting to lock <0x918d4790> (a org.apache.lucene.index.IndexWriter)
	at org.apache.lucene.index.IndexWriter.mergeMiddle(IndexWriter.java:4243)
	at org.apache.lucene.index.IndexWriter.merge(IndexWriter.java:3884)
	at org.apache.lucene.index.ConcurrentMergeScheduler.doMerge(ConcurrentMergeScheduler.java:205)
	at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:260)


"Indexer" prio=1 tid=0x08b6a7f0 nid=0x221c waiting on condition [0x8af92000..0x8af92dc0]
	at java.lang.Throwable.fillInStackTrace(Native Method)
	at java.lang.Throwable.<init>(Throwable.java:181)
	at java.lang.Exception.<init>(Exception.java:29)
	at java.lang.InterruptedException.<init>(InterruptedException.java:31)
	at java.lang.Object.wait(Native Method)
	at org.apache.lucene.index.IndexWriter.doWait(IndexWriter.java:4494)
	- locked <0x918d4790> (a org.apache.lucene.index.IndexWriter)
	at org.apache.lucene.index.IndexWriter.finishMerges(IndexWriter.java:2809)
	- locked <0x918d4790> (a org.apache.lucene.index.IndexWriter)
	at org.apache.lucene.index.IndexWriter.closeInternal(IndexWriter.java:1647)
	at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1602)
	at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1578)
	at com.inet.helpdesk.search.Indexer.indiziereBuendel(Indexer.java:542)
	at com.inet.helpdesk.search.Indexer.indexBuendel(Indexer.java:353)
	at com.inet.helpdesk.search.Indexer.run(Indexer.java:243)


> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680888#action_12680888 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------


bq. I've changed only IndexWriter.close() to IndexWriter.close(true). The true is correct.

But that's identical to IndexWriter.close(), which simply calls close(true).

bq. After some testing we couldn't reproduce the lock anymore. So I think it is solved with this change.

I don't see how it's possible calling close(true) resolved the issue;
it must be after more testing you'll see it's still there.  I'd really
like to get to the root cause.

bq. I'm not doing any external synchronization on IndexWriter myself. I expect that the IndexWriter is synchronized by itself.

Right, IndexWriter is fully thread-safe; I wanted to make sure you
don't have any of your own code that tries to do
synchronized(writer) {...}.

bq. Sure there are many threads running, but these are the only two threads, that have to do with the indexing.

Can you post all of the threads traces?

When you hit the deadlock, if you wait a few seconds and get the
thread traces again, have they changed?

Can you make this happen on a smallish test case?


> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12690101#action_12690101 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------

It's possible this is the same issue as LUCENE-1573.

> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Stefan Heidrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680861#action_12680861 ] 

Stefan Heidrich commented on LUCENE-1555:
-----------------------------------------

First of all, I could solve the problem by using IndexWriter.close(true) instead of IndexWriter.close().

The indexer thread will index new data periodically. But if the indexer threat is started, it will perform an optimize as well. So it could happen that

((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

and 

indexWriter = new IndexWriter(indexDirectory, analyser , false, MaxFieldLength.UNLIMITED);
indexWriter.optimize(MAX_MERGED_FILES);
((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

will be executed one after another. With close() this could result in a lock.
I've only changed the maxFieldLength of the writer to 50000.



> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-1555.
----------------------------------------

    Resolution: Incomplete

Need more details here.

> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Assigned: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless reassigned LUCENE-1555:
------------------------------------------

    Assignee: Michael McCandless

> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680441#action_12680441 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------

Those thread stack traces actually look completely normal.  Were there other threads involved?  Can you post them?

Are you running with assertions enabled?  (The first stack trace is on an assert line, which is interesting).

Also, if you're on Unix, with modern JREs if you "kill -QUIT" the process then it'll give you all threads, and the stacktrace will include details about which locks are held (your stack traces above don't seem to include this).

Are you certain you were in deadlock, vs an optimize that was taking a long time to run?

How easy is it to reproduce this?

> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Stefan Heidrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680873#action_12680873 ] 

Stefan Heidrich commented on LUCENE-1555:
-----------------------------------------

I've changed only IndexWriter.close() to IndexWriter.close(true). The true is correct.

After some testing we couldn't reproduce the lock anymore. So I think it is solved with this change.

I've expected, that calling ConcurrentMergeScheduler.sync() would prevents the lock, but that was not the case.

I'm not doing any external synchronization on IndexWriter myself. I expect that the IndexWriter is synchronized by itself.
The indexer thread is the only thread that uses the IndexWriter and calling IndexWriter.close(). 

Sure there are  many threads running, but these are the only two threads, that have to do with the indexing.

> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680864#action_12680864 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------

bq. First of all, I could solve the problem by using IndexWriter.close(true) instead of IndexWriter.close().

Did you mean false instead of true?  (waitForMerges=true is what
close() does by default).

This (false) is dangerous to do, always, since it could result in merge
starvation whereby long-running merges never have a chance to
complete (I just updated 2.9 javadocs to state this).

{quote}
The indexer thread will index new data periodically. But if the indexer threat is started, it will perform an optimize as well. So it could happen that

((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

and

indexWriter = new IndexWriter(indexDirectory, analyser , false, MaxFieldLength.UNLIMITED);
indexWriter.optimize(MAX_MERGED_FILES);
((ConcurrentMergeScheduler)indexWriter.getMergeScheduler()).sync();
indexWriter.close(true);

will be executed one after another. With close() this could result in a lock.
{quote}

I don't really follow what you're saying here.  Are you saying calling
ConcurrentMergeScheduler.sync() leads to the deadlock, or, prevents
it?

By indexer thread, do you mean you are launching your own threads to
do indexing, or are you talking about ConcurrentMergeScheduler's
threads?

Are you doing any external synchronization on IndexWriter yourself?

Are you calling IndexWriter.close() from multiple threads?

Can you post every thread in your thread dump?  (Or, is it really the
case that you only have 2 threads?).

bq. I've only changed the maxFieldLength of the writer to 50000.

OK that's fine.


> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (LUCENE-1555) Deadlock while optimize

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-1555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680856#action_12680856 ] 

Michael McCandless commented on LUCENE-1555:
--------------------------------------------


bq. It seems that the IndexWriter tries to lock two times.

Right, but the 2nd thread has called wait(), which internally releases
the lock, pauses, then tries to reaquire the lock and return.  So this
still looks relatively normal to me so far.

In this case, one thread has called IndexWriter.close.  That thread is
waiting for all merges to finish.  Another thread is trying to commit
a merge... but I don't understand why that other thread is blocked
trying to acquire the lock.

Have you changed the default settings on IndexWriter at all?  EG
number of merge threads, RAM buffer size, etc.?

Can you answer my other questions above?


> Deadlock while optimize
> -----------------------
>
>                 Key: LUCENE-1555
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1555
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4
>         Environment: ubuntu 8.04, java 1.6 update 07, Lucene 2.4.0
>            Reporter: Stefan Heidrich
>            Assignee: Michael McCandless
>
> Sometimes after starting the thread with the indexer, the thread will hang in the following threads.
> Thread [Lucene Merge Thread #0] (Ausgesetzt)	
> 	IndexWriter.commitMerge(MergePolicy$OneMerge, SegmentMerger, int) Line: 3751	
> 	IndexWriter.mergeMiddle(MergePolicy$OneMerge) Line: 4240	
> 	IndexWriter.merge(MergePolicy$OneMerge) Line: 3877	
> 	ConcurrentMergeScheduler.doMerge(MergePolicy$OneMerge) Line: 205	
> 	ConcurrentMergeScheduler$MergeThread.run() Line: 260	
> Thread [Indexer] (Ausgesetzt)	
> 	Object.wait(long) Line: not available [native Methode]	
> 	IndexWriter.doWait() Line: 4491	
> 	IndexWriter.optimize(int, boolean) Line: 2268	
> 	IndexWriter.optimize(boolean) Line: 2203	
> 	IndexWriter.optimize() Line: 2183	
> 	Indexer.run() Line: 263	
> If you need more informations, please let me know.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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