lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject [lucene-solr] branch branch_8x updated: SOLR-14351: commitScheduler was missing MDC logging (#1498)
Date Thu, 14 May 2020 01:03:39 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/branch_8x by this push:
     new f00b38d  SOLR-14351: commitScheduler was missing MDC logging (#1498)
f00b38d is described below

commit f00b38d004831512de21ed1f8289b2e939dafbd3
Author: David Smiley <dsmiley@apache.org>
AuthorDate: Wed May 13 20:58:07 2020 -0400

    SOLR-14351: commitScheduler was missing MDC logging (#1498)
    
    (cherry picked from commit 4b9808a03d6c8ee1f1f71487372a689b6c5f9798)
---
 .../src/java/org/apache/solr/update/CommitTracker.java   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 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 cf8dee6..0f7c153 100644
--- a/solr/core/src/java/org/apache/solr/update/CommitTracker.java
+++ b/solr/core/src/java/org/apache/solr/update/CommitTracker.java
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.logging.MDCLoggingContext;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.common.util.SolrNamedThreadFactory;
@@ -57,8 +58,10 @@ public final class CommitTracker implements Runnable {
   private int docsUpperBound;
   private long timeUpperBound;
   private long tLogFileSizeUpperBound;
-  
-  private final ScheduledExecutorService scheduler = 
+
+  // note: can't use ExecutorsUtil because it doesn't have a *scheduled* ExecutorService.
+  //  Not a big deal but it means we must take care of MDC logging here.
+  private final ScheduledExecutorService scheduler =
       Executors.newScheduledThreadPool(1, new SolrNamedThreadFactory("commitScheduler"));
   private ScheduledFuture pending;
   
@@ -248,9 +251,8 @@ public final class CommitTracker implements Runnable {
       pending = null;  // allow a new commit to be scheduled
     }
 
-    SolrQueryRequest req = new LocalSolrQueryRequest(core,
-        new ModifiableSolrParams());
-    try {
+    MDCLoggingContext.setCore(core);
+    try (SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams()))
{
       CommitUpdateCommand command = new CommitUpdateCommand(req, false);
       command.openSearcher = openSearcher;
       command.waitSearcher = WAIT_SEARCHER;
@@ -271,9 +273,9 @@ public final class CommitTracker implements Runnable {
     } catch (Exception e) {
       SolrException.log(log, "auto commit error...", e);
     } finally {
-      // log.info("###done committing");
-      req.close();
+      MDCLoggingContext.clear();
     }
+    // log.info("###done committing");
   }
   
   // to facilitate testing: blocks if called during commit


Mime
View raw message