fix test failure; add fangs to testcase

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1531590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-10-12 20:36:42 +00:00
parent c6989394ff
commit 00dcd8c161
3 changed files with 34 additions and 13 deletions

View File

@ -1027,18 +1027,15 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
infoStream.message("IW", "now call final commit()");
}
// Must do this before commitInternal, in case any of
// the dropped readers in the pool wrote a new live
// docs:
synchronized(this) {
readerPool.dropAll(true);
}
if (doFlush) {
commitInternal();
}
synchronized(this) {
// commitInternal calls ReaderPool.commit, which
// writes any pending liveDocs from ReaderPool, so
// it's safe to drop all readers now:
readerPool.dropAll(true);
deleter.close();
}

View File

@ -1313,6 +1313,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// to fail in "more evil" places inside BDS
shouldFail.set(true);
boolean doClose = false;
try {
@ -1333,9 +1334,16 @@ public class TestIndexWriterDelete extends LuceneTestCase {
// throw the exc):
assertEquals(docCount-deleteCount, r.numDocs());
r.close();
// TODO: also call w.close() in here, sometimes,
// so we sometimes get a fail via dropAll
// Sometimes close, so the disk full happens on close:
if (random().nextBoolean()) {
if (VERBOSE) {
System.out.println(" now close writer");
}
doClose = true;
w.close();
w = null;
}
} catch (FakeIOException ioe) {
// expected
@ -1348,13 +1356,23 @@ public class TestIndexWriterDelete extends LuceneTestCase {
IndexReader r;
if (random().nextBoolean()) {
if (doClose && w != null) {
if (VERBOSE) {
System.out.println(" now 2nd close writer");
}
w.close();
w = null;
}
if (w == null || random().nextBoolean()) {
// Open non-NRT reader, to make sure the "on
// disk" bits are good:
if (VERBOSE) {
System.out.println("TEST: verify against non-NRT reader");
}
w.commit();
if (w != null) {
w.commit();
}
r = DirectoryReader.open(dir);
} else {
if (VERBOSE) {
@ -1366,7 +1384,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
r.close();
// Sometimes re-use RIW, other times open new one:
if (random().nextBoolean()) {
if (w != null && random().nextBoolean()) {
if (VERBOSE) {
System.out.println("TEST: close writer");
}

View File

@ -177,6 +177,9 @@ public class TestIndexWriterWithThreads extends LuceneTestCase {
int NUM_THREADS = 3;
int numIterations = TEST_NIGHTLY ? 7 : 3;
for(int iter=0;iter<numIterations;iter++) {
if (VERBOSE) {
System.out.println("\nTEST: iter=" + iter);
}
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(
@ -209,6 +212,9 @@ public class TestIndexWriterWithThreads extends LuceneTestCase {
}
}
if (VERBOSE) {
System.out.println("\nTEST: now close");
}
writer.close(false);
// Make sure threads that are adding docs are not hung: