Issue Details (XML | Word | Printable)

Key: LUCENE-1200
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael McCandless
Reporter: Michael McCandless
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

IndexWriter.addIndexes* can deadlock in rare cases

Created: 04/Mar/08 10:14 AM   Updated: 08/May/08 07:47 PM
Return to search
Component/s: Index
Affects Version/s: 2.4
Fix Version/s: 2.3.2, 2.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LUCENE-1200.patch 2008-03-04 10:17 AM Michael McCandless 9 kB

Lucene Fields: New
Resolution Date: 06/Mar/08 11:52 AM


 Description  « Hide
In somewhat rare cases it's possible for addIndexes to deadlock
because it is a synchronized method.

Normally the merges that are necessary for addIndexes are done
serially (with the primary thread) because they involve segments from
an external directory. However, if mergeFactor of these merges
complete then a merge becomes necessary for the merged segments, which
are not external, and so it can run in the background. If too many BG
threads need to run (currently > 4) then the "pause primary thread"
approach adopted in LUCENE-1164 will deadlock, because the addIndexes
method is holding a lock on IndexWriter.

This was appearing as a intermittant deadlock in the
TestIndexWriterMerging test case.

This issue is not present in 2.3 (it was caused by LUCENE-1164).

The solution is to shrink the scope of synchronization: don't
synchronize on the whole method & wrap synchronized(this) in the right
places inside the methods.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael McCandless added a comment - 04/Mar/08 10:17 AM
Attached patch. I plan to commit in a day or two.

Hoss Man added a comment - 11/Mar/08 07:29 PM
targeted for 2.3.2 bug fix release