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

Shai Erera commented on LUCENE-1703:
------------------------------------

May I ask what's the use case for this? I looked at IndexWriter and the 
following have doWait versions: close(), optimize() and expungeDeletes(). The 
only one that doesn't is commit(), which documents it will not wait for merges. 
So this seems to be a method just for

{code}
try { 
  writer.commit(); 
} finally { 
  writer.waitForMerges(); 
}
{code}

Is there any other use case that you would want to wait for merges to finish?

It's just that adding methods means we need to support them going forward, and 
if there's no real use case (or at least none that is covered by current API), 
we should not do it?

> Add a waitForMerges() method to IndexWriter
> -------------------------------------------
>
>                 Key: LUCENE-1703
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1703
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Index
>    Affects Versions: 2.4
>            Reporter: Tim Smith
>         Attachments: IndexWriter.java.diff
>
>
> It would be very useful to have a waitForMerges() method on the IndexWriter.
> Right now, the only way i can see to achieve this is to call 
> IndexWriter.close()
> ideally, there would be a method on the IndexWriter to wait for merges 
> without actually closing the index.
> This would make it so that background merges (or optimize) can be waited for 
> without closing the IndexWriter, and then reopening a new IndexWriter
> the close() reopen IndexWriter method can be problematic if the close() fails 
> as the write lock won't be released
> this could then result in the following sequence:
> * close() - fails
> * force unlock the write lock (per close() documentation)
> * new IndexWriter() (acquires write lock)
> * finalize() on old IndexWriter releases the write lock
> * Index is now not locked, and another IndexWriter pointing to the same 
> directory could be opened
> If you don't force unlock the write lock, opening a new IndexWriter will fail 
> until garbage collection calls finalize() the old IndexWriter
> If the waitForMerges() method is available, i would likely never need to 
> close() the IndexWriter until right before the process being shutdown, so 
> this issue would not occur (worst case scenario, the waitForMerges() fails)

-- 
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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to