LUCENE-6835, LUCENE-6684: keep the 'suppress NSFE on windows' hack inside IFD as well

This commit is contained in:
Mike McCandless 2016-02-08 13:54:05 -05:00
parent 5e6f22b925
commit 2cee9f1693
2 changed files with 19 additions and 9 deletions

View File

@ -705,14 +705,29 @@ final class IndexFileDeleter implements Closeable {
if (name.startsWith(IndexFileNames.SEGMENTS) == false) {
continue;
}
directory.deleteFile(name);
deleteFile(name);
}
for(String name : names) {
if (name.startsWith(IndexFileNames.SEGMENTS) == true) {
continue;
}
directory.deleteFile(name);
deleteFile(name);
}
}
private void deleteFile(String fileName) throws IOException {
try {
directory.deleteFile(fileName);
} catch (NoSuchFileException | FileNotFoundException e) {
if (Constants.WINDOWS) {
// TODO: can we remove this OS-specific hacky logic? If windows deleteFile is buggy, we should instead contain this workaround in
// a WindowsFSDirectory ...
// LUCENE-6684: we suppress this assert for Windows, since a file could be in a confusing "pending delete" state, where we already
// deleted it once, yet it still shows up in directory listings, and if you try to delete it again you'll hit NSFE/FNFE:
} else {
throw e;
}
}
}

View File

@ -233,19 +233,14 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
iwc.setOpenMode(OpenMode.APPEND);
try {
writer = new IndexWriter(dir, iwc);
} catch (LockObtainFailedException e) {
// lock obtain timed out
// NOTE: we should at some point
// consider this a failure? The lock
// obtains, across IndexReader &
// IndexWriters should be "fair" (ie
// FIFO).
} catch (Throwable t) {
if (Constants.WINDOWS && t instanceof AccessDeniedException) {
// LUCENE-6684: suppress this: on Windows, a file in the curious "pending delete" state can
// cause this exc on IW init, where one thread/process deleted an old
// segments_N, but the delete hasn't finished yet because other threads/processes
// still have it open
printStream.println("TEST: AccessDeniedException on init witer");
t.printStackTrace(printStream);
} else {
hitException = true;
System.out.println("Stress Test Index Writer: creation hit unexpected exception: " + t.toString());