This is an automated email from the ASF dual-hosted git repository. jsweeney pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit 1934c56aca7c4a20d9156d5ae67b639556d25b81 Author: patsonluk <[email protected]> AuthorDate: Wed Jul 5 05:17:04 2023 -0700 SOLR-16861: Correct(override) MDC info for `CoordinatorHttpSolrCall` (#1753) --- .../solr/servlet/CoordinatorHttpSolrCall.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java index a9448d1310c..df95f712a4c 100644 --- a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java +++ b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java @@ -37,6 +37,7 @@ import org.apache.solr.common.util.Utils; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreDescriptor; import org.apache.solr.core.SolrCore; +import org.apache.solr.logging.MDCLoggingContext; import org.apache.solr.request.DelegatingSolrQueryRequest; import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.SolrQueryRequest; @@ -73,9 +74,11 @@ public class CoordinatorHttpSolrCall extends HttpSolrCall { public static SolrCore getCore( Factory factory, HttpSolrCall solrCall, String collectionName, boolean isPreferLeader) { - String sytheticCoreName = factory.collectionVsCoreNameMapping.get(collectionName); - if (sytheticCoreName != null) { - return solrCall.cores.getCore(sytheticCoreName); + String syntheticCoreName = factory.collectionVsCoreNameMapping.get(collectionName); + if (syntheticCoreName != null) { + SolrCore syntheticCore = solrCall.cores.getCore(syntheticCoreName); + setMDCLoggingContext(collectionName); + return syntheticCore; } else { ZkStateReader zkStateReader = solrCall.cores.getZkController().getZkStateReader(); ClusterState clusterState = zkStateReader.getClusterState(); @@ -117,12 +120,26 @@ public class CoordinatorHttpSolrCall extends HttpSolrCall { addReplica(syntheticCollectionName, solrCall.cores); core = solrCall.getCoreByCollection(syntheticCollectionName, isPreferLeader); } + setMDCLoggingContext(collectionName); return core; } return null; } } + /** + * Overrides the MDC context as the core set was synthetic core, which does not reflect the + * collection being operated on + */ + private static void setMDCLoggingContext(String collectionName) { + MDCLoggingContext.setCollection(collectionName); + + // below is irrelevant for call to coordinator + MDCLoggingContext.setCoreName(null); + MDCLoggingContext.setShard(null); + MDCLoggingContext.setCoreName(null); + } + private static void addReplica(String syntheticCollectionName, CoreContainer cores) { SolrQueryResponse rsp = new SolrQueryResponse(); try {
