From 777ab0397248fa1514e8cc7b981f0a95c23cf742 Mon Sep 17 00:00:00 2001 From: Doug Cutting Date: Fri, 26 May 2006 16:14:12 +0000 Subject: [PATCH] LUCENE-485. Don't hold commit lock while removing obsolete index files. Contributed by Luc Vanlerberghe. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@409690 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ .../org/apache/lucene/index/IndexWriter.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7985cd517ba..8bd5536306a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -81,6 +81,10 @@ Bug fixes 15. LUCENE-546: Removed 2GB file size limitations for RAMDirectory. (Peter Royal, Michael Chan, Yonik Seeley) +16. LUCENE-485: Don't hold commit lock while removing obsolete index + files. (Luc Vanlerberghe via cutting) + + 1.9.1 Bug fixes diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index e839e9b89bc..c1d9ef64922 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -614,12 +614,13 @@ public class IndexWriter { new Lock.With(directory.makeLock(COMMIT_LOCK_NAME), commitLockTimeout) { public Object doBody() throws IOException { segmentInfos.write(directory); // commit changes - deleteSegments(segmentsToDelete); // delete now-unused segments return null; } }.run(); } + deleteSegments(segmentsToDelete); // delete now-unused segments + if (useCompoundFile) { final Vector filesToDelete = merger.createCompoundFile(mergedName + ".tmp"); synchronized (directory) { // in- & inter-process sync @@ -627,12 +628,13 @@ public class IndexWriter { public Object doBody() throws IOException { // make compound file visible for SegmentReaders directory.renameFile(mergedName + ".tmp", mergedName + ".cfs"); - // delete now unused files of segment - deleteFiles(filesToDelete); return null; } }.run(); } + + // delete now unused files of segment + deleteFiles(filesToDelete); } } @@ -722,12 +724,13 @@ public class IndexWriter { new Lock.With(directory.makeLock(COMMIT_LOCK_NAME), commitLockTimeout) { public Object doBody() throws IOException { segmentInfos.write(directory); // commit before deleting - deleteSegments(segmentsToDelete); // delete now-unused segments return null; } }.run(); } + deleteSegments(segmentsToDelete); // delete now-unused segments + if (useCompoundFile) { final Vector filesToDelete = merger.createCompoundFile(mergedName + ".tmp"); synchronized (directory) { // in- & inter-process sync @@ -735,12 +738,13 @@ public class IndexWriter { public Object doBody() throws IOException { // make compound file visible for SegmentReaders directory.renameFile(mergedName + ".tmp", mergedName + ".cfs"); - // delete now unused files of segment - deleteFiles(filesToDelete); return null; } }.run(); } + + // delete now unused files of segment + deleteFiles(filesToDelete); } }