Hi,
> > I know there were good reasons for eliminating the "autoCommit" > > functionality from IndexWriter, but threads like tis make me thing thta > > even though "autoCommit" on flush/merge/whatever was bad, having an > option > > for some sort of "autoClose" using a finalizer might by a good idea to > > give new/novice users a safety net. > > > > In the case of totally successful normal operation, this would result in > > one commit at GC (assuming the JVM calls the finalizer) and if there were > > any errors it should (if i understnad correclty) do an implicit rollback. > > > > Anyone see a downside? > I think finalize() is that not trustworthy, in that it may never be called, e.g. in case GC happened to not collect the specific object, and so the way for programmers to guarantee execution of any code at shutdown is with shutdown hooks, I guess this is that what you meant, that Lucene would add a shutdown hook? I.e, each IndexWriter object opened for write would add its own method as a shutdown hook, so that at shutdown, that writer would check its state, and in case that it was not closed (and hence also not rolled-back) and has pending uncommitted changes, those changes would be committed, is this what you mean? I think it is almost okay - it would save the use case of this thread, but could still surprise someone... Perhaps there's a third option - "semi-commit"? - that is, with the proposed shutdown hook, iw commits without deleting the previous commit, and marks on dir that its state is "semi-commit" and so when that index is opened for read or write it would throw a special new exception that indicates this stare, and the caller, before continuing to use this index for either read or write would have to call either one of two new utility methods: - commitSemiCommit(Directory) - roolbackSemiCommit(Directory) (Perhaps better names, rollbackSelfCommit, rollbackPartialCommit, etc.) After that, it would be possible to open the index as usual. It seems to me that something like this can work. Not totally convinced that it is worth the effort...? > Yes. Totally unexpected magical behaviour. > What if I didn't commit something on purporse? > Applications can call rollback() in this case. Regards, Doron