You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/03/07 18:33:26 UTC

[GitHub] [lucene-solr] dnhatn opened a new pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

dnhatn opened a new pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331
 
 
   Add some tests that perform a set of operations randomly and concurrently on IndexWriter.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] mikemccand commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#discussion_r389389305
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
 ##########
 @@ -3775,4 +3777,120 @@ public void testRefreshAndRollbackConcurrently() throws Exception {
       IOUtils.close(sm, dir);
     }
   }
+
+  public void testRandomOperations() throws Exception {
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    iwc.setMergePolicy(new FilterMergePolicy(newMergePolicy()) {
+      boolean keepFullyDeletedSegment = random().nextBoolean();
+
+      @Override
+      public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
+        return keepFullyDeletedSegment;
+      }
+    });
+    try (Directory dir = newDirectory();
+         IndexWriter writer = new IndexWriter(dir, iwc);
+         SearcherManager sm = new SearcherManager(writer, new SearcherFactory())) {
+      Semaphore permits = new Semaphore(10 + random().nextInt(1000));
 
 Review comment:
   This is the number of operations (across all threads) we will execute?  Maybe rename it to `numOperations` or something?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dnhatn commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
dnhatn commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#discussion_r389393993
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
 ##########
 @@ -3775,4 +3777,120 @@ public void testRefreshAndRollbackConcurrently() throws Exception {
       IOUtils.close(sm, dir);
     }
   }
+
+  public void testRandomOperations() throws Exception {
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    iwc.setMergePolicy(new FilterMergePolicy(newMergePolicy()) {
+      boolean keepFullyDeletedSegment = random().nextBoolean();
+
+      @Override
+      public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
+        return keepFullyDeletedSegment;
+      }
+    });
+    try (Directory dir = newDirectory();
+         IndexWriter writer = new IndexWriter(dir, iwc);
+         SearcherManager sm = new SearcherManager(writer, new SearcherFactory())) {
+      Semaphore permits = new Semaphore(10 + random().nextInt(1000));
 
 Review comment:
   ++. Adjusted in https://github.com/apache/lucene-solr/pull/1331/commits/e3fd5ce0643d7a05fd0b530b20b58e7b5589cd2a.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dnhatn closed pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
dnhatn closed pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] msokolov commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
msokolov commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#discussion_r389304104
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
 ##########
 @@ -3775,4 +3777,120 @@ public void testRefreshAndRollbackConcurrently() throws Exception {
       IOUtils.close(sm, dir);
     }
   }
+
+  public void testRandomOperations() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    iwc.setMergePolicy(new FilterMergePolicy(newMergePolicy()) {
+      boolean keepFullyDeletedSegment = random().nextBoolean();
+      @Override
+      public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
+        return keepFullyDeletedSegment;
+      }
+    });
+    IndexWriter writer = new IndexWriter(dir, iwc);
+    SearcherManager sm = new SearcherManager(writer, new SearcherFactory());
+    Semaphore permits = new Semaphore(100 + random().nextInt(1000));
+    boolean singleDoc = random().nextBoolean();
+    Thread[] threads = new Thread[1 + random().nextInt(4)];
+    CountDownLatch latch = new CountDownLatch(threads.length);
+    for (int i = 0; i < threads.length; i++) {
+      threads[i] = new Thread(() -> {
+        latch.countDown();
+        try {
+          latch.await();
+          while (permits.tryAcquire()) {
+            String id = singleDoc ? "1" : Integer.toString(random().nextInt(10));
+            Document doc = new Document();
+            doc.add(new StringField("id", id, Field.Store.YES));
+            if (random().nextInt(10) <= 2) {
+              writer.updateDocument(new Term("id", id), doc);
+            } else if (random().nextInt(10) <= 2) {
+              writer.deleteDocuments(new Term("id", id));
+            } else {
+              writer.addDocument(doc);
+            }
+            if (random().nextInt(100) < 10) {
+              sm.maybeRefreshBlocking();
+            }
+            if (random().nextInt(100) < 5) {
+              writer.commit();
+            }
+            if (random().nextInt(100) < 1) {
+              writer.forceMerge(1 + random().nextInt(10), random().nextBoolean());
+            }
+          }
+        } catch (Exception e) {
+          throw new AssertionError(e);
+        }
+      });
+      threads[i].start();
+    }
+    for (Thread thread : threads) {
+      thread.join();
+    }
+    sm.maybeRefreshBlocking();
+    IOUtils.close(writer, sm, dir);
+  }
+
+  public void testRandomOperationsWithSoftDeletes() throws Exception {
+    Directory dir = newDirectory();
 
 Review comment:
   can we use try-with-resources to ensure proper closure of Directory, IndexWriter, and SearcherManager on failure?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] msokolov commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
msokolov commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#discussion_r389304196
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
 ##########
 @@ -3775,4 +3777,120 @@ public void testRefreshAndRollbackConcurrently() throws Exception {
       IOUtils.close(sm, dir);
     }
   }
+
+  public void testRandomOperations() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    iwc.setMergePolicy(new FilterMergePolicy(newMergePolicy()) {
+      boolean keepFullyDeletedSegment = random().nextBoolean();
+      @Override
+      public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
+        return keepFullyDeletedSegment;
+      }
+    });
+    IndexWriter writer = new IndexWriter(dir, iwc);
+    SearcherManager sm = new SearcherManager(writer, new SearcherFactory());
+    Semaphore permits = new Semaphore(100 + random().nextInt(1000));
+    boolean singleDoc = random().nextBoolean();
+    Thread[] threads = new Thread[1 + random().nextInt(4)];
+    CountDownLatch latch = new CountDownLatch(threads.length);
+    for (int i = 0; i < threads.length; i++) {
+      threads[i] = new Thread(() -> {
+        latch.countDown();
+        try {
+          latch.await();
+          while (permits.tryAcquire()) {
+            String id = singleDoc ? "1" : Integer.toString(random().nextInt(10));
+            Document doc = new Document();
+            doc.add(new StringField("id", id, Field.Store.YES));
+            if (random().nextInt(10) <= 2) {
+              writer.updateDocument(new Term("id", id), doc);
+            } else if (random().nextInt(10) <= 2) {
+              writer.deleteDocuments(new Term("id", id));
+            } else {
+              writer.addDocument(doc);
+            }
+            if (random().nextInt(100) < 10) {
+              sm.maybeRefreshBlocking();
+            }
+            if (random().nextInt(100) < 5) {
+              writer.commit();
+            }
+            if (random().nextInt(100) < 1) {
+              writer.forceMerge(1 + random().nextInt(10), random().nextBoolean());
+            }
+          }
+        } catch (Exception e) {
+          throw new AssertionError(e);
+        }
+      });
+      threads[i].start();
+    }
+    for (Thread thread : threads) {
+      thread.join();
+    }
+    sm.maybeRefreshBlocking();
+    IOUtils.close(writer, sm, dir);
+  }
+
+  public void testRandomOperationsWithSoftDeletes() throws Exception {
+    Directory dir = newDirectory();
 
 Review comment:
   Hmm I don't see where to officially +1 this in github, but thanks for sharing these tests!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dnhatn commented on issue #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
dnhatn commented on issue #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#issuecomment-596128237
 
 
   @msokolov Thanks for looking. I pushed https://github.com/apache/lucene-solr/pull/1331/commits/9e9b53271372d6a884b8de019c4aec7fed7dd97f to use try-with-resources for them.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] mikemccand commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
mikemccand commented on a change in pull request #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#discussion_r389389331
 
 

 ##########
 File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
 ##########
 @@ -3775,4 +3777,120 @@ public void testRefreshAndRollbackConcurrently() throws Exception {
       IOUtils.close(sm, dir);
     }
   }
+
+  public void testRandomOperations() throws Exception {
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    iwc.setMergePolicy(new FilterMergePolicy(newMergePolicy()) {
+      boolean keepFullyDeletedSegment = random().nextBoolean();
+
+      @Override
+      public boolean keepFullyDeletedSegment(IOSupplier<CodecReader> readerIOSupplier) {
+        return keepFullyDeletedSegment;
+      }
+    });
+    try (Directory dir = newDirectory();
+         IndexWriter writer = new IndexWriter(dir, iwc);
+         SearcherManager sm = new SearcherManager(writer, new SearcherFactory())) {
+      Semaphore permits = new Semaphore(10 + random().nextInt(1000));
+      boolean singleDoc = random().nextBoolean();
+      Thread[] threads = new Thread[1 + random().nextInt(4)];
+      CountDownLatch latch = new CountDownLatch(threads.length);
+      for (int i = 0; i < threads.length; i++) {
+        threads[i] = new Thread(() -> {
+          latch.countDown();
+          try {
+            latch.await();
+            while (permits.tryAcquire()) {
+              String id = singleDoc ? "1" : Integer.toString(random().nextInt(10));
+              Document doc = new Document();
+              doc.add(new StringField("id", id, Field.Store.YES));
+              if (random().nextInt(10) <= 2) {
+                writer.updateDocument(new Term("id", id), doc);
+              } else if (random().nextInt(10) <= 2) {
+                writer.deleteDocuments(new Term("id", id));
+              } else {
+                writer.addDocument(doc);
+              }
+              if (random().nextInt(100) < 10) {
+                sm.maybeRefreshBlocking();
+              }
+              if (random().nextInt(100) < 5) {
+                writer.commit();
+              }
+              if (random().nextInt(100) < 1) {
+                writer.forceMerge(1 + random().nextInt(10), random().nextBoolean());
+              }
+            }
+          } catch (Exception e) {
+            throw new AssertionError(e);
+          }
+        });
+        threads[i].start();
+      }
+      for (Thread thread : threads) {
+        thread.join();
+      }
+    }
+  }
+
+  public void testRandomOperationsWithSoftDeletes() throws Exception {
+    IndexWriterConfig iwc = newIndexWriterConfig();
+    AtomicInteger seqNo = new AtomicInteger(-1);
+    AtomicInteger retainingSeqNo = new AtomicInteger();
+    iwc.setSoftDeletesField("soft_deletes");
+    iwc.setMergePolicy(new SoftDeletesRetentionMergePolicy("soft_deletes",
+        () -> LongPoint.newRangeQuery("seq_no", retainingSeqNo.longValue(), Long.MAX_VALUE), newMergePolicy()));
+    try (Directory dir = newDirectory();
+         IndexWriter writer = new IndexWriter(dir, iwc);
+         SearcherManager sm = new SearcherManager(writer, new SearcherFactory())) {
+      Semaphore permits = new Semaphore(10 + random().nextInt(1000));
 
 Review comment:
   Also here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] dnhatn commented on issue #1331: LUCENE-9268: Add some random tests to IndexWriter

Posted by GitBox <gi...@apache.org>.
dnhatn commented on issue #1331: LUCENE-9268: Add some random tests to IndexWriter
URL: https://github.com/apache/lucene-solr/pull/1331#issuecomment-596310852
 
 
   @msokolov @mikemccand Thanks for review.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org