You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2020/05/14 00:58:22 UTC
[lucene-solr] branch master updated: SOLR-14351: commitScheduler
was missing MDC logging (#1498)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 4b9808a SOLR-14351: commitScheduler was missing MDC logging (#1498)
4b9808a is described below
commit 4b9808a03d6c8ee1f1f71487372a689b6c5f9798
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed May 13 20:58:07 2020 -0400
SOLR-14351: commitScheduler was missing MDC logging (#1498)
---
.../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