You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2018/04/26 10:47:38 UTC

lucene-solr:branch_7x: LUCENE-8275: Fix BaseLockFactoryTestCase to step out on Windowns if pending files are found

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 93d5fc0b1 -> 6ff100731


LUCENE-8275: Fix BaseLockFactoryTestCase to step out on Windowns if pending files are found

The particular test here is #testStressLocks that has several protectesion against
WindowsFS and special logic in the catch clause that steps out on fatal exceptions with
pending deletes. Since we now check this consistently in the IW ctor we need to also
skip this entire test if we are on windows and have pending deletes.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6ff10073
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6ff10073
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6ff10073

Branch: refs/heads/branch_7x
Commit: 6ff100731b93fdde22905fc0a4517438677b981a
Parents: 93d5fc0
Author: Simon Willnauer <si...@apache.org>
Authored: Thu Apr 26 11:51:58 2018 +0200
Committer: Simon Willnauer <si...@apache.org>
Committed: Thu Apr 26 12:46:52 2018 +0200

----------------------------------------------------------------------
 .../TestIndexWriterOutOfFileDescriptors.java      |  5 +++++
 .../lucene/store/BaseLockFactoryTestCase.java     | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6ff10073/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java
index 290e051..2d2ce8f 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOutOfFileDescriptors.java
@@ -25,6 +25,7 @@ import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.Constants;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase;
@@ -65,6 +66,10 @@ public class TestIndexWriterOutOfFileDescriptors extends LuceneTestCase {
         if (ms instanceof ConcurrentMergeScheduler) {
           ((ConcurrentMergeScheduler) ms).setSuppressExceptions();
         }
+        if (Constants.WINDOWS && dir.checkPendingDeletions()) {
+          // if we are on windows and we have pending deletions we can't execute this test
+          break;
+        }
         w = new IndexWriter(dir, iwc);
         if (r != null && random().nextInt(5) == 3) {
           if (random().nextBoolean()) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6ff10073/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
index 312b644..12f2204 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
@@ -172,11 +172,10 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
     SearcherThread searcher = new SearcherThread(100, dir);
     writer.start();
     searcher.start();
-    
-    while(writer.isAlive() || searcher.isAlive()) {
-      Thread.sleep(1000);
-    }
-    
+
+    writer.join();
+    searcher.join();
+
     assertTrue("IndexWriter hit unexpected exceptions", !writer.hitException);
     assertTrue("IndexSearcher hit unexpected exceptions", !searcher.hitException);
     
@@ -232,14 +231,20 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
         printStream.println("\nTEST: WriterThread iter=" + i);
         iwc.setOpenMode(OpenMode.APPEND);
         try {
+          if (Constants.WINDOWS && dir.checkPendingDeletions()) {
+            // on windows we can potentially have pending deletes here if this happens we step out like in the catch clause
+            // tests using this also assumes no mock window FS
+            break;
+          }
           writer = new IndexWriter(dir, iwc);
+
         } 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");
+            printStream.println("TEST: AccessDeniedException on init writer");
             t.printStackTrace(printStream);
           } else {
             hitException = true;
@@ -268,7 +273,6 @@ public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
             System.out.println(toString(baos));
             break;
           }
-          writer = null;
         }
       }
     }