LUCENE-4456: close merged readers first, then checkpoint

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1394464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-10-05 12:01:23 +00:00
parent 53fd5c850d
commit b6c924e26d
1 changed files with 21 additions and 9 deletions

View File

@ -3211,15 +3211,27 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
deleter.deleteNewFiles(merge.info.files());
}
// Must note the change to segmentInfos so any commits
// in-flight don't lose it (IFD will incRef/protect the
// new files we created):
checkpoint();
// Must close before checkpoint, otherwise IFD won't be
// able to delete the held-open files from the merge
// readers:
closeMergeReaders(merge, false);
boolean success = false;
try {
// Must close before checkpoint, otherwise IFD won't be
// able to delete the held-open files from the merge
// readers:
closeMergeReaders(merge, false);
success = true;
} finally {
// Must note the change to segmentInfos so any commits
// in-flight don't lose it (IFD will incRef/protect the
// new files we created):
if (success) {
checkpoint();
} else {
try {
checkpoint();
} catch (Throwable t) {
// Ignore so we keep throwing original exception.
}
}
}
deleter.deletePendingFiles();