From 7708b88c3078c5ec9750769b293179513dd57eb8 Mon Sep 17 00:00:00 2001 From: patsonluk Date: Fri, 15 Sep 2023 15:01:08 -0700 Subject: [PATCH] Log refCount and core name if refCount of SolrCore is > 1 after SolrDispatchFilter finishes processing it. --- .../org/apache/solr/servlet/SolrDispatchFilter.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java index cfd9836c4ed..36ba8694cf9 100644 --- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java +++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java @@ -49,6 +49,7 @@ import org.apache.solr.common.util.SuppressForbidden; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.NodeRoles; +import org.apache.solr.core.SolrCore; import org.apache.solr.handler.api.V2ApiUtils; import org.apache.solr.logging.MDCLoggingContext; import org.apache.solr.logging.MDCSnapshot; @@ -275,6 +276,18 @@ private void dispatch( } } finally { call.destroy(); + SolrCore core = call.getCore(); + if (core != null) { + int coreRefCount = core.getOpenCount(); + if (coreRefCount > 1) { + if (log.isInfoEnabled()) + log.info( + "Core {} has ref count of {} . It's still used by other logic even if the current servlet request {} finishes", + core.getName(), + coreRefCount, + call.getReq().getServletPath()); + } + } ExecutorUtil.setServerThreadFlag(null); } }