Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 48045 invoked from network); 18 Dec 2009 10:34:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Dec 2009 10:34:59 -0000 Received: (qmail 44264 invoked by uid 500); 18 Dec 2009 10:34:59 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 44180 invoked by uid 500); 18 Dec 2009 10:34:58 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 44171 invoked by uid 99); 18 Dec 2009 10:34:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2009 10:34:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2009 10:34:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4D5CB23889B8; Fri, 18 Dec 2009 10:34:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r892211 - in /lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene: ./ index/ Date: Fri, 18 Dec 2009 10:34:35 -0000 To: java-commits@lucene.apache.org From: uschindler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091218103435.4D5CB23889B8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: uschindler Date: Fri Dec 18 10:34:34 2009 New Revision: 892211 URL: http://svn.apache.org/viewvc?rev=892211&view=rev Log: LUCENE-2170: Fix thread starvation problems in BW branch Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestAtomicUpdate.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterReader.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestStressIndexing.java lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestTransactions.java Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java Fri Dec 18 10:34:34 2009 @@ -122,7 +122,7 @@ public void run() { Document doc = new Document(); doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); - while(System.currentTimeMillis() < stopTime) { + do { for(int i=0;i<27;i++) { try { writer.addDocument(doc); @@ -143,7 +143,7 @@ } catch (InterruptedException ie) { throw new ThreadInterruptedException(ie); } - } + } while(System.currentTimeMillis() < stopTime); } }; @@ -151,12 +151,10 @@ // While the above indexing thread is running, take many // backups: - while(System.currentTimeMillis() < stopTime) { + do { backupIndex(dir, dp); Thread.sleep(20); - if (!t.isAlive()) - break; - } + } while(t.isAlive()); t.join(); Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestAtomicUpdate.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestAtomicUpdate.java Fri Dec 18 10:34:34 2009 @@ -47,7 +47,7 @@ } private static abstract class TimedThread extends Thread { - boolean failed; + volatile boolean failed; int count; private static float RUN_TIME_SEC = 0.5f; private TimedThread[] allThreads; @@ -65,10 +65,11 @@ count = 0; try { - while(System.currentTimeMillis() < stopTime && !anyErrors()) { + do { + if (anyErrors()) break; doWork(); count++; - } + } while(System.currentTimeMillis() < stopTime); } catch (Throwable e) { System.out.println(Thread.currentThread().getName() + ": exc"); e.printStackTrace(System.out); Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Dec 18 10:34:34 2009 @@ -2204,7 +2204,7 @@ int fullCount = 0; final long stopTime = System.currentTimeMillis() + 200; - while(System.currentTimeMillis() < stopTime) { + do { try { writer.updateDocument(new Term("id", ""+(idUpto++)), doc); addCount++; @@ -2238,7 +2238,7 @@ } break; } - } + } while(System.currentTimeMillis() < stopTime); } } Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Fri Dec 18 10:34:34 2009 @@ -65,7 +65,7 @@ final long stopTime = System.currentTimeMillis() + 500; - while(System.currentTimeMillis() < stopTime) { + do { doFail.set(this); final String id = ""+r.nextInt(50); idField.setValue(id); @@ -105,7 +105,7 @@ failure = t; break; } - } + } while(System.currentTimeMillis() < stopTime); } } Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterReader.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestIndexWriterReader.java Fri Dec 18 10:34:34 2009 @@ -730,14 +730,14 @@ threads[i] = new Thread() { @Override public void run() { - while(System.currentTimeMillis() < endTime) { + do { try { writer.addIndexesNoOptimize(dirs); } catch (Throwable t) { excs.add(t); throw new RuntimeException(t); } - } + } while(System.currentTimeMillis() < endTime); } }; threads[i].setDaemon(true); @@ -760,6 +760,15 @@ for(int i=0;i= lastCount); assertEquals(0, excs.size()); writer.close(); @@ -796,7 +805,7 @@ public void run() { int count = 0; final Random r = new Random(); - while(System.currentTimeMillis() < endTime) { + do { try { for(int i=0;i<10;i++) { writer.addDocument(createDocument(10*count+i, "test", 4)); @@ -811,7 +820,7 @@ excs.add(t); throw new RuntimeException(t); } - } + } while(System.currentTimeMillis() < endTime); } }; threads[i].setDaemon(true); @@ -832,7 +841,16 @@ for(int i=0;i 0); + // at least search once + IndexReader r2 = r.reopen(); + if (r2 != r) { + r.close(); + r = r2; + } + Query q = new TermQuery(new Term("indexname", "test")); + sum += new IndexSearcher(r).search(q, 10).totalHits; + + assertTrue("no documents found at all", sum > 0); assertEquals(0, excs.size()); writer.close(); Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestStressIndexing.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestStressIndexing.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestStressIndexing.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestStressIndexing.java Fri Dec 18 10:34:34 2009 @@ -31,7 +31,7 @@ private Random RANDOM; private static abstract class TimedThread extends Thread { - boolean failed; + volatile boolean failed; int count; private static int RUN_TIME_SEC = 1; private TimedThread[] allThreads; @@ -49,10 +49,11 @@ count = 0; try { - while(System.currentTimeMillis() < stopTime && !anyErrors()) { + do { + if (anyErrors()) break; doWork(); count++; - } + } while(System.currentTimeMillis() < stopTime); } catch (Throwable e) { System.out.println(Thread.currentThread() + ": exc"); e.printStackTrace(System.out); Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestTransactions.java URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestTransactions.java?rev=892211&r1=892210&r2=892211&view=diff ============================================================================== --- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestTransactions.java (original) +++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestTransactions.java Fri Dec 18 10:34:34 2009 @@ -38,7 +38,7 @@ } private static abstract class TimedThread extends Thread { - boolean failed; + volatile boolean failed; private static float RUN_TIME_SEC = 0.5f; private TimedThread[] allThreads; @@ -53,8 +53,10 @@ final long stopTime = System.currentTimeMillis() + (long) (1000*RUN_TIME_SEC); try { - while(System.currentTimeMillis() < stopTime && !anyErrors()) + do { + if (anyErrors()) break; doWork(); + } while (System.currentTimeMillis() < stopTime); } catch (Throwable e) { System.out.println(Thread.currentThread() + ": exc"); e.printStackTrace(System.out);