diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index c14c5d7991a..5a80d06dad3 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -158,6 +158,7 @@ Other Changes * SOLR-9498: Remove HDFS properties from DIH solrconfig.xml, as started in SOLR-6943 (Alexandre Rafalovitch) +* SOLR-9365: Reduce noise in solr logs during graceful shutdown. (Cao Manh Dat via shalin) ================== 6.2.1 ================== diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java index 8560d3a45b0..644ad22c9ab 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java +++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java @@ -288,8 +288,12 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { String coreName = leaderProps.getStr(ZkStateReader.CORE_NAME_PROP); ActionThrottle lt; try (SolrCore core = cc.getCore(coreName)) { - if (core == null) { - throw new SolrException(ErrorCode.SERVER_ERROR, "SolrCore not found:" + coreName + " in " + cc.getCoreNames()); + if (core == null ) { + if (cc.isShutDown()) { + return; + } else { + throw new SolrException(ErrorCode.SERVER_ERROR, "SolrCore not found:" + coreName + " in " + cc.getCoreNames()); + } } MDCLoggingContext.setCore(core); lt = core.getUpdateHandler().getSolrCoreState().getLeaderThrottle(); @@ -325,9 +329,13 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { try (SolrCore core = cc.getCore(coreName)) { if (core == null) { - cancelElection(); - throw new SolrException(ErrorCode.SERVER_ERROR, - "SolrCore not found:" + coreName + " in " + cc.getCoreNames()); + if (!zkController.getCoreContainer().isShutDown()) { + cancelElection(); + throw new SolrException(ErrorCode.SERVER_ERROR, + "SolrCore not found:" + coreName + " in " + cc.getCoreNames()); + } else { + return; + } } // should I be leader? diff --git a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java index e71ddf09b9b..719bc5f2c91 100644 --- a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java +++ b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java @@ -347,7 +347,9 @@ public class LeaderElector { // am I the next leader? checkIfIamLeader(context, true); } catch (Exception e) { - log.warn("", e); + if (!zkClient.isClosed()) { + log.warn("", e); + } } } } diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java index 074cf163c4a..b736d1bdaf5 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerTaskProcessor.java @@ -176,7 +176,9 @@ public class OverseerTaskProcessor implements Runnable, Closeable { try { prioritizer.prioritizeOverseerNodes(myId); } catch (Exception e) { - log.error("Unable to prioritize overseer ", e); + if (!zkStateReader.getZkClient().isClosed()) { + log.error("Unable to prioritize overseer ", e); + } } // TODO: Make maxThreads configurable. diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java index 516b7b947c8..f2b67ee1bf5 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java @@ -32,6 +32,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.List; import java.util.concurrent.ExecutorService; +import java.util.concurrent.RejectedExecutionException; import java.util.regex.Pattern; import org.apache.commons.io.FileUtils; @@ -263,7 +264,14 @@ public class SolrZkClient implements Closeable { @Override public void process(final WatchedEvent event) { log.debug("Submitting job to respond to event " + event); - zkCallbackExecutor.submit(() -> watcher.process(event)); + try { + zkCallbackExecutor.submit(() -> watcher.process(event)); + } catch (RejectedExecutionException e) { + // If not a graceful shutdown + if (!isClosed()) { + throw e; + } + } } }; }