You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/26 01:09:52 UTC

[lucene-solr] branch reference_impl updated: @332 Tweak commit tracker close.

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

markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl by this push:
     new fa06727  @332 Tweak commit tracker close.
fa06727 is described below

commit fa0672784c4a0513c6800526a633b39b41a821c1
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sat Jul 25 20:08:59 2020 -0500

    @332 Tweak commit tracker close.
---
 .../core/src/java/org/apache/solr/update/CommitTracker.java | 13 ++++++++-----
 .../org/apache/solr/common/util/SolrQueuedThreadPool.java   |  1 +
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/CommitTracker.java b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
index d673a72..5a22513 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitTracker.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
@@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.solr.common.ParWork;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.ExecutorUtil;
@@ -67,7 +68,7 @@ public final class CommitTracker implements Runnable, Closeable {
   private final ScheduledExecutorService scheduler =
       Executors.newScheduledThreadPool(1, new SolrNamedThreadFactory("commitScheduler"));
   @SuppressWarnings({"rawtypes"})
-  private ScheduledFuture pending;
+  private volatile ScheduledFuture pending;
   
   // state
   private AtomicLong docsSinceCommit = new AtomicLong(0);
@@ -105,12 +106,14 @@ public final class CommitTracker implements Runnable, Closeable {
   
   public synchronized void close() {
     this.closed = true;
-    if (pending != null) {
+    try {
       pending.cancel(false);
-      pending = null;
+    } catch (NullPointerException e) {
+      // okay
     }
-    scheduler.shutdown();
-    ExecutorUtil.awaitTermination(scheduler);
+    pending = null;
+
+    ParWork.close(scheduler);
     ObjectReleaseTracker.release(this);
   }
   
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index 45940fe..4dc89dd 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -48,6 +48,7 @@ import org.eclipse.jetty.util.thread.TryExecutor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+// TODO we can inherit from jetty impl now and just override newThread
 public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFactory, ThreadPool.SizedThreadPool, Dumpable, TryExecutor, Closeable {
     private static final org.eclipse.jetty.util.log.Logger LOG = Log.getLogger(QueuedThreadPool.class);
     private static Runnable NOOP = () ->