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/09/01 22:46:46 UTC

[lucene-solr] 01/02: @683 Try to pin down rare updatelog leak.

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

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

commit 337faafc722d77d65d0776f035c33396fad0a485
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Sep 1 17:31:11 2020 -0500

    @683 Try to pin down rare updatelog leak.
---
 .../java/org/apache/solr/update/UpdateHandler.java | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index bed48c9..59a99bc 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -57,9 +57,10 @@ UpdateHandler implements SolrInfoBean, Closeable {
   protected Vector<SolrEventListener> softCommitCallbacks = new Vector<>();
   protected Vector<SolrEventListener> optimizeCallbacks = new Vector<>();
 
-  protected volatile UpdateLog ulog;
+  protected final UpdateLog ulog;
 
   protected SolrMetricsContext solrMetricsContext;
+  protected volatile boolean closed;
 
   private void parseEventListeners() {
     final Class<SolrEventListener> clazz = SolrEventListener.class;
@@ -96,6 +97,7 @@ UpdateHandler implements SolrInfoBean, Closeable {
 
   @Override
   public void close() throws IOException {
+    this.closed = true;
     if (ulog != null) ulog.close();
     ObjectReleaseTracker.release(this);
   }
@@ -123,6 +125,7 @@ UpdateHandler implements SolrInfoBean, Closeable {
   }
   
   public UpdateHandler(SolrCore core, UpdateLog updateLog)  {
+    UpdateLog ourUpdateLog = null;
     ObjectReleaseTracker.track(this);
     try {
       this.core = core;
@@ -136,29 +139,34 @@ UpdateHandler implements SolrInfoBean, Closeable {
       if (updateLog == null && ulogPluginInfo != null && ulogPluginInfo.isEnabled() && !skipUpdateLog) {
         DirectoryFactory dirFactory = core.getDirectoryFactory();
         if (dirFactory instanceof HdfsDirectoryFactory) {
-          ulog = new HdfsUpdateLog(((HdfsDirectoryFactory) dirFactory).getConfDir());
+          ourUpdateLog = new HdfsUpdateLog(((HdfsDirectoryFactory) dirFactory).getConfDir());
         } else {
           String className = ulogPluginInfo.className == null ? UpdateLog.class.getName() : ulogPluginInfo.className;
-          ulog = core.getResourceLoader().newInstance(className, UpdateLog.class, "update.");
+          ourUpdateLog = core.getResourceLoader().newInstance(className, UpdateLog.class, "update.");
         }
 
         if (!core.isReloaded() && !dirFactory.isPersistent()) {
-          ulog.clearLog(core, ulogPluginInfo);
+          ourUpdateLog.clearLog(core, ulogPluginInfo);
         }
 
         if (log.isInfoEnabled()) {
-          log.info("Using UpdateLog implementation: {}", ulog.getClass().getName());
+          log.info("Using UpdateLog implementation: {}", ourUpdateLog.getClass().getName());
+        }
+        ourUpdateLog.init(ulogPluginInfo);
+        ourUpdateLog.init(this, core);
+        if (updateLog != null) {
+          updateLog.close();
         }
-        ulog.init(ulogPluginInfo);
-        ulog.init(this, core);
       } else {
-        ulog = updateLog;
+        ourUpdateLog = updateLog;
       }
     } catch (Exception e) {
-      IOUtils.closeQuietly(ulog);
+      IOUtils.closeQuietly(ourUpdateLog);
       ObjectReleaseTracker.release(this);
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
     }
+
+    ulog = ourUpdateLog;
   }
 
   /**