[
https://issues.apache.org/jira/browse/LUCENE-4246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13539245#comment-13539245
]
Michael McCandless commented on LUCENE-4246:
--------------------------------------------
bq. The proper way to close IndexWriter should be: writer.close()
But I don't like the trap this sets up on apps that upgrade ... so if
there are pending uncommitted changes, IW.close should throw an exc
(IllegalStateExc?). Ie, the app must be explicit about discarding or
committing those changes, before calling close.
Separately, if there are running merges then we should throw a similar
exception, otherwise we set up a denial-of-service on biggish merges
trap: for apps that open a writer, index a batch of docs, and close
the writer, a given biggish merge would forever kick off when the
writer is opened and then be aborted when it's closed, wasting CPU/IO
and never finishing the merge.
If we handle those two traps then I'm OK with making close "just
close". The "proper" shutdown sequence for IW would then be:
{noformat}
w.waitForMerges() OR w.abortMerges()
w.commit() OR w.rollback()
w.close()
{noformat}
(And we'd fix rollback to not close).
Shai objected to how verbose this is for "normal" usage, and I agree,
so I proposed adding a sugar mehod "commitAndClose" that would just
call waitForMerges(), commit(), close(). I was hoping to hear from
Shai whether that's an OK compromise...
bq. Although close() may do more than just closing (if autocommit is enabled,
it may also commit), they decided to add Closeable (e.g., see
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html) - but the
discussion here was similar.
That's an interesting precedent. Uwe do you a pointer to the
discussion?
So I think another option here is to leave close as is (it waits for
merges, commits) except, if an exception is thrown, it suppresses that
exception, finishes closing, and then throws it. Like IOUtils.close
...
This way on calling IW.close(), if an exception is thrown, the IW will
in fact have been closed / relased its lock / etc., and then the app
sees the first exception that was hit while closing.
Hmm... does java.io.Closeable document semantics on exception? Ie if
I call RAF.close and hit an exception, is it "really closed"? It does
document that calling it more than once is fine ...
> Fix IndexWriter.close() to not commit or wait for pending merges
> ----------------------------------------------------------------
>
> Key: LUCENE-4246
> URL: https://issues.apache.org/jira/browse/LUCENE-4246
> Project: Lucene - Core
> Issue Type: Bug
> Reporter: Robert Muir
> Assignee: Robert Muir
> Fix For: 4.1
>
>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]