You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/05/10 02:04:13 UTC

[solr] branch branch_9x updated (35980d5f410 -> b48bf0e18a1)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


    from 35980d5f410 SOLR-16179 : Updated the documentation as reported in the ticket , along with the examples (#835)
     new 215633699fc SOLR-16186: AuditLoggerPluginTest leaks threads
     new b48bf0e18a1 SOLR-16189: TestCancellableCollector thread leak (#847)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/solr/security/AuditLoggerPlugin.java  | 14 +++++++++-----
 .../org/apache/solr/search/TestCancellableCollector.java  | 15 ++++++++-------
 2 files changed, 17 insertions(+), 12 deletions(-)


[solr] 02/02: SOLR-16189: TestCancellableCollector thread leak (#847)

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit b48bf0e18a1dbb90559978c680841e1debf457b3
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Mon May 9 22:01:07 2022 -0400

    SOLR-16189: TestCancellableCollector thread leak (#847)
---
 .../org/apache/solr/search/TestCancellableCollector.java  | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java b/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
index d31ca82a07c..7e76bacc2ec 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCancellableCollector.java
@@ -39,9 +39,9 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.search.TopScoreDocCollector;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NamedThreadFactory;
 import org.apache.solr.SolrTestCase;
 import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
 
 public class TestCancellableCollector extends SolrTestCase {
   Directory dir;
@@ -78,8 +78,8 @@ public class TestCancellableCollector extends SolrTestCase {
             4,
             0L,
             TimeUnit.MILLISECONDS,
-            new LinkedBlockingQueue<Runnable>(),
-            new NamedThreadFactory("TestIndexSearcher"));
+            new LinkedBlockingQueue<>(),
+            new SolrNamedThreadFactory(this.getClass().getSimpleName()));
   }
 
   @Override
@@ -89,10 +89,9 @@ public class TestCancellableCollector extends SolrTestCase {
     dir.close();
 
     if (executor != null) {
-      executor.shutdown();
+      ExecutorUtil.shutdownAndAwaitTermination(executor);
+      executor = null;
     }
-
-    executor = null;
   }
 
   private CancellableCollector buildCancellableCollector(
@@ -121,7 +120,6 @@ public class TestCancellableCollector extends SolrTestCase {
   private void cancelQuery(CancellableCollector cancellableCollector, final int sleepTime) {
     executor.submit(
         () -> {
-
           // Wait for some time to let the query start
           try {
             if (sleepTime > 0) {
@@ -130,6 +128,7 @@ public class TestCancellableCollector extends SolrTestCase {
 
             cancellableCollector.cancel();
           } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new RuntimeException(e.getMessage());
           }
         });
@@ -200,6 +199,7 @@ public class TestCancellableCollector extends SolrTestCase {
         try {
           Thread.sleep(50);
         } catch (InterruptedException e) {
+          Thread.currentThread().interrupt();
           throw new RuntimeException(e.getMessage());
         }
       }
@@ -212,6 +212,7 @@ public class TestCancellableCollector extends SolrTestCase {
             try {
               Thread.sleep(30);
             } catch (InterruptedException e) {
+              Thread.currentThread().interrupt();
               throw new RuntimeException(e.getMessage());
             }
           }


[solr] 01/02: SOLR-16186: AuditLoggerPluginTest leaks threads

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 215633699fcb84329440d41749772c1ef89cbb30
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Mon May 9 21:59:52 2022 -0400

    SOLR-16186: AuditLoggerPluginTest leaks threads
---
 .../java/org/apache/solr/security/AuditLoggerPlugin.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java b/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java
index 07a8dd73740..62d6d952220 100644
--- a/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java
+++ b/solr/core/src/java/org/apache/solr/security/AuditLoggerPlugin.java
@@ -42,9 +42,11 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.ExecutorUtil;
 import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.core.SolrInfoBean;
 import org.apache.solr.metrics.SolrMetricsContext;
 import org.apache.solr.security.AuditEvent.EventType;
+import org.apache.solr.util.TimeOut;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -348,7 +350,8 @@ public abstract class AuditLoggerPlugin implements Closeable, Runnable, SolrInfo
       waitForQueueToDrain(30);
       closed = true;
       log.info("Shutting down async Auditlogger background thread(s)");
-      executorService.shutdownNow();
+      ExecutorUtil.shutdownNowAndAwaitTermination(executorService);
+      executorService = null;
       try {
         SolrInfoBean.super.close();
       } catch (Exception e) {
@@ -364,8 +367,8 @@ public abstract class AuditLoggerPlugin implements Closeable, Runnable, SolrInfo
    */
   protected void waitForQueueToDrain(int timeoutSeconds) {
     if (async && executorService != null) {
-      int timeSlept = 0;
-      while ((!queue.isEmpty() || auditsInFlight.get() > 0) && timeSlept < timeoutSeconds) {
+      TimeOut timeOut = new TimeOut(timeoutSeconds, TimeUnit.SECONDS, TimeSource.NANO_TIME);
+      while ((!queue.isEmpty() || auditsInFlight.get() > 0) && !timeOut.hasTimedOut()) {
         try {
           if (log.isInfoEnabled()) {
             log.info(
@@ -373,9 +376,10 @@ public abstract class AuditLoggerPlugin implements Closeable, Runnable, SolrInfo
                 queue.size(),
                 auditsInFlight.get());
           }
-          Thread.sleep(1000);
-          timeSlept++;
+          timeOut.sleep(1000);
         } catch (InterruptedException ignored) {
+          // Preserve interrupt status
+          Thread.currentThread().interrupt();
         }
       }
     }