Skip to content

Commit

Permalink
also rollback commit if SegmentInfos.files(..) throws exc; delete seg…
Browse files Browse the repository at this point in the history
…ments file one exc during finishCommit

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_0@1395405 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mikemccand committed Oct 7, 2012
1 parent 260080b commit 12226ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4076,10 +4076,11 @@ private void startCommit(final SegmentInfos toSync, final Map<String,String> com
}

// This call can take a long time -- 10s of seconds
// or more. We do it without sync:
// or more. We do it without syncing on this:
boolean success = false;
final Collection<String> filesToSync = toSync.files(directory, false);
final Collection<String> filesToSync;
try {
filesToSync = toSync.files(directory, false);
directory.sync(filesToSync);
success = true;
} finally {
Expand Down
11 changes: 5 additions & 6 deletions lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ final void finishCommit(Directory dir) throws IOException {
success = true;
} finally {
if (!success) {
IOUtils.closeWhileHandlingException(pendingSegnOutput);
// Closes pendingSegnOutput & deletes partial segments_N:
rollbackCommit(dir);
} else {
success = false;
Expand All @@ -928,12 +928,11 @@ final void finishCommit(Directory dir) throws IOException {
success = true;
} finally {
if (!success) {
final String segmentFileName = IndexFileNames.fileNameFromGeneration(IndexFileNames.SEGMENTS,
"",
generation);
IOUtils.deleteFilesIgnoringExceptions(dir, segmentFileName);
// Closes pendingSegnOutput & deletes partial segments_N:
rollbackCommit(dir);
} else {
pendingSegnOutput = null;
}
pendingSegnOutput = null;
}
}
}
Expand Down

0 comments on commit 12226ce

Please sign in to comment.