This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_10x by this push:
     new 22230419802 SOLR-17934: Remove Request ID based tracing (#3709)
22230419802 is described below

commit 22230419802145e382f3676979b60f27bd1736b4
Author: Eric Pugh <[email protected]>
AuthorDate: Fri Dec 19 10:50:03 2025 -0500

    SOLR-17934: Remove Request ID based tracing (#3709)
---
 .../deprecation_removal_char_SOLR-17934.yml        | 10 +++
 .../solr/handler/component/DebugComponent.java     |  8 +-
 .../solr/handler/component/ResponseBuilder.java    |  3 +
 .../solr/handler/component/SearchHandler.java      | 84 +-------------------
 .../org/apache/solr/handler/TestRequestId.java     | 91 ----------------------
 .../solr/handler/component/DebugComponentTest.java | 28 +------
 .../component/DistributedDebugComponentTest.java   |  1 -
 .../apache/solr/common/params/CommonParams.java    | 20 -----
 .../src/resources/EnvToSyspropMappings.properties  |  1 -
 9 files changed, 18 insertions(+), 228 deletions(-)

diff --git a/changelog/unreleased/deprecation_removal_char_SOLR-17934.yml 
b/changelog/unreleased/deprecation_removal_char_SOLR-17934.yml
new file mode 100644
index 00000000000..69b6e0d622b
--- /dev/null
+++ b/changelog/unreleased/deprecation_removal_char_SOLR-17934.yml
@@ -0,0 +1,10 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+title: Remove Request ID based tracing.
+type: removed
+authors:
+  - name: Eric Pugh
+links:
+  - name: SOLR-17934
+    url: https://issues.apache.org/jira/browse/SOLR-17934
+issues:
+  - 17934
diff --git 
a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java 
b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
index 42d39efa708..3fb01bd7da6 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
@@ -73,7 +73,7 @@ public class DebugComponent extends SearchComponent {
   public void prepare(ResponseBuilder rb) throws IOException {
     if (rb.isDebugTrack() && rb.isDistrib) {
       rb.setNeedDocList(true);
-      doDebugTrack(rb);
+      rb.addDebug(new SimpleOrderedMap<>(), "track");
     }
   }
 
@@ -140,11 +140,6 @@ public class DebugComponent extends SearchComponent {
     }
   }
 
-  private void doDebugTrack(ResponseBuilder rb) {
-    final String rid = rb.req.getParams().get(CommonParams.REQUEST_ID);
-    rb.addDebug(rid, "track", CommonParams.REQUEST_ID); // to see it in the 
response
-  }
-
   @Override
   public void modifyRequest(ResponseBuilder rb, SearchComponent who, 
ShardRequest sreq) {
     if (!rb.isDebug()) return;
@@ -176,7 +171,6 @@ public class DebugComponent extends SearchComponent {
     }
     if (rb.isDebugTrack()) {
       sreq.params.add(CommonParams.DEBUG, CommonParams.TRACK);
-      sreq.params.set(CommonParams.REQUEST_ID, 
rb.req.getParams().get(CommonParams.REQUEST_ID));
       sreq.params.set(
           CommonParams.REQUEST_PURPOSE, 
SolrPluginUtils.getRequestPurpose(sreq.purpose));
     }
diff --git 
a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java 
b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
index 596e9edddd0..413a962683b 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java
@@ -344,6 +344,9 @@ public class ResponseBuilder {
   }
 
   public NamedList<Object> getDebugInfo() {
+    if (debugInfo == null) {
+      debugInfo = new SimpleOrderedMap<>();
+    }
     return debugInfo;
   }
 
diff --git 
a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java 
b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index 9811ba618db..7ccc3b4e32a 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -41,7 +41,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import org.apache.lucene.index.ExitableDirectoryReader;
@@ -57,13 +56,11 @@ import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.ShardParams;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.core.CloseHook;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.RequestHandlerBase;
-import org.apache.solr.logging.MDCLoggingContext;
 import org.apache.solr.metrics.SolrMetricsContext;
 import org.apache.solr.pkg.PackageAPI;
 import org.apache.solr.pkg.PackageListeners;
@@ -86,7 +83,6 @@ import org.apache.solr.util.plugin.PluginInfoInitialized;
 import org.apache.solr.util.plugin.SolrCoreAware;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
 
 /** Refer SOLR-281 */
 public class SearchHandler extends RequestHandlerBase
@@ -99,27 +95,6 @@ public class SearchHandler extends RequestHandlerBase
 
   private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-  /**
-   * A counter to ensure that no RID is equal, even if they fall in the same 
millisecond
-   *
-   * @deprecated this was replaced by the auto-generated trace ids
-   */
-  @Deprecated(since = "9.4")
-  private static final AtomicLong ridCounter = new AtomicLong();
-
-  /**
-   * An opt-out flag to prevent the addition of {@link 
CommonParams#REQUEST_ID} tracing on
-   * distributed queries
-   *
-   * <p>Defaults to 'false' if not specified.
-   *
-   * @see CommonParams#DISABLE_REQUEST_ID
-   * @deprecated this was replaced by the auto-generated trace ids
-   */
-  @Deprecated(since = "9.4")
-  private static final boolean DISABLE_REQUEST_ID_DEFAULT =
-      Boolean.getBoolean("solr.disableRequestId");
-
   private HandlerMetrics metricsShard = HandlerMetrics.NO_OP;
 
   protected volatile List<SearchComponent> components;
@@ -250,8 +225,7 @@ public class SearchHandler extends RequestHandlerBase
     }
 
     rb.isDistrib = isDistrib(req, rb); // can change later nonetheless
-    tagRequestWithRequestId(rb);
-
+    
     boolean dbg = req.getParams().getBool(CommonParams.DEBUG_QUERY, false);
     rb.setDebug(dbg);
     if (dbg == false) { // if it's true, we are doing everything anyway.
@@ -868,62 +842,6 @@ public class SearchHandler extends RequestHandlerBase
     }
   }
 
-  private void tagRequestWithRequestId(ResponseBuilder rb) {
-    final boolean ridTaggingDisabled =
-        rb.req.getParams().getBool(CommonParams.DISABLE_REQUEST_ID, 
DISABLE_REQUEST_ID_DEFAULT);
-    if (!ridTaggingDisabled) {
-      String rid = getOrGenerateRequestId(rb.req);
-
-      // NOTE: SearchHandler explicitly never clears/removes this MDC value...
-      // We want it to live for the entire request, beyond the scope of 
SearchHandler's processing,
-      // and trust SolrDispatchFilter to clean it up at the end of the request.
-      //
-      // Examples:
-      // - ERROR logging of Exceptions propogated up to our base class
-      // - SolrCore.RequestLog
-      // - ERRORs that may be logged during response writing
-      MDC.put(CommonParams.REQUEST_ID, rid);
-
-      if (StrUtils.isBlank(rb.req.getParams().get(CommonParams.REQUEST_ID))) {
-        ModifiableSolrParams params = new 
ModifiableSolrParams(rb.req.getParams());
-        params.add(CommonParams.REQUEST_ID, rid); // add rid to the request so 
that shards see it
-        rb.req.setParams(params);
-      }
-      if (rb.isDistrib) {
-        rb.rsp.addToLog(CommonParams.REQUEST_ID, rid); // to see it in the 
logs of the landing core
-      }
-    }
-  }
-
-  /**
-   * Returns a String to use as an identifier for this request.
-   *
-   * <p>If the provided {@link SolrQueryRequest} contains a non-blank {@link
-   * CommonParams#REQUEST_ID} param value this is used. This is especially 
useful for users who
-   * deploy Solr as one component in a larger ecosystem, and want to use an 
external ID utilized by
-   * other components as well. If no {@link CommonParams#REQUEST_ID} value is 
present, one is
-   * generated from scratch for the request.
-   *
-   * <p>Callers are responsible for storing the returned value in the {@link 
SolrQueryRequest}
-   * object if they want to ensure that ID generation is not redone on 
subsequent calls.
-   */
-  public static String getOrGenerateRequestId(SolrQueryRequest req) {
-    String rid = req.getParams().get(CommonParams.REQUEST_ID);
-    if (StrUtils.isNotBlank(rid)) {
-      return rid;
-    }
-    String traceId = MDCLoggingContext.getTraceId();
-    if (StrUtils.isNotBlank(traceId)) {
-      return traceId;
-    }
-    return generateRid(req);
-  }
-
-  private static String generateRid(SolrQueryRequest req) {
-    String hostName = req.getCoreContainer().getHostName();
-    return hostName + "-" + ridCounter.getAndIncrement();
-  }
-
   //////////////////////// SolrInfoMBeans methods //////////////////////
 
   @Override
diff --git a/solr/core/src/test/org/apache/solr/handler/TestRequestId.java 
b/solr/core/src/test/org/apache/solr/handler/TestRequestId.java
deleted file mode 100644
index e8692ce1d38..00000000000
--- a/solr/core/src/test/org/apache/solr/handler/TestRequestId.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.handler;
-
-import static org.hamcrest.core.StringContains.containsString;
-
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.SuppressForbidden;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.util.LogListener;
-import org.junit.BeforeClass;
-import org.slf4j.MDC;
-
-@SuppressForbidden(reason = "We need to use log4J2 classes directly to test 
MDC impacts")
-public class TestRequestId extends SolrTestCaseJ4 {
-
-  @BeforeClass
-  public static void beforeTests() throws Exception {
-    initCore("solrconfig.xml", "schema.xml");
-  }
-
-  public void testRequestId() {
-
-    try (LogListener reqLog = LogListener.info(SolrCore.class.getName() + 
".Request")) {
-
-      // Check that our MDC doesn't already have some sort of rid set in it
-      assertNull(MDC.get(CommonParams.REQUEST_ID));
-
-      // simple request that should successfully be logged ...
-      assertQ("xxx", req("q", "*:*", CommonParams.REQUEST_ID, "xxx"), 
"//*[@numFound='0']");
-
-      // Sanity check that the test framework didn't let our "request" MDC 
info "leak" out of
-      // assertQ...
-      assertNull(MDC.get(CommonParams.REQUEST_ID));
-
-      {
-        var reqEvent = reqLog.getQueue().poll();
-        assertNotNull(reqEvent);
-        assertEquals("xxx", reqEvent.getContextData().getValue("rid"));
-        assertTrue(reqLog.getQueue().isEmpty());
-      }
-
-      // request that should cause some ERROR logging...
-      // NOTE: we can't just listen for errors at the 'root' logger because 
assertQEx will 'mute'
-      // them before we can intercept
-      try (LogListener errLog = LogListener.error(RequestHandlerBase.class)) {
-        assertQEx(
-            "yyy",
-            "bogus_yyy",
-            req("q", "*:*", "sort", "bogus_yyy", CommonParams.REQUEST_ID, 
"yyy"),
-            ErrorCode.BAD_REQUEST);
-
-        // Sanity check that the test framework didn't let our "request" MDC 
info "leak" out of
-        // assertQEx...
-        assertNull(MDC.get(CommonParams.REQUEST_ID));
-
-        {
-          var reqEvent = reqLog.getQueue().poll();
-          assertNotNull(reqEvent);
-          assertEquals("yyy", reqEvent.getContextData().getValue("rid"));
-          assertThat(
-              reqEvent.getMessage().getFormattedMessage(),
-              containsString("status=" + ErrorCode.BAD_REQUEST.code));
-        }
-        {
-          var errEvent = errLog.getQueue().poll();
-          assertNotNull(errEvent);
-          assertEquals("yyy", errEvent.getContextData().getValue("rid"));
-          assertNotNull(errEvent.getThrown());
-        }
-      }
-    }
-  }
-}
diff --git 
a/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java 
b/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java
index 9778a4bb078..973765cb524 100644
--- 
a/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java
+++ 
b/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java
@@ -23,7 +23,6 @@ import java.util.List;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.NamedList;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
@@ -32,8 +31,6 @@ import org.junit.Test;
 /** */
 public class DebugComponentTest extends SolrTestCaseJ4 {
 
-  private static final String ANY_RID = "ANY_RID";
-
   @BeforeClass
   public static void beforeClass() throws Exception {
     initCore("solrconfig.xml", "schema.xml");
@@ -166,8 +163,7 @@ public class DebugComponentTest extends SolrTestCaseJ4 {
     List<SearchComponent> components = new ArrayList<>(1);
     components.add(component);
     for (int i = 0; i < 10; i++) {
-      SolrQueryRequest req =
-          req("q", "test query", "distrib", "true", CommonParams.REQUEST_ID, 
"123456-my_rid");
+      SolrQueryRequest req = req("q", "test query", "distrib", "true");
       SolrQueryResponse resp = new SolrQueryResponse();
       ResponseBuilder rb = new ResponseBuilder(req, resp, components);
       ShardRequest sreq = new ShardRequest();
@@ -192,8 +188,6 @@ public class DebugComponentTest extends SolrTestCaseJ4 {
       // the purpose must be added as readable param to be included in the 
shard logs
       assertEquals(
           "GET_FIELDS,GET_DEBUG,SET_TERM_STATS", 
sreq.params.get(CommonParams.REQUEST_PURPOSE));
-      // the rid must be added to be included in the shard logs
-      assertEquals("123456-my_rid", sreq.params.get(CommonParams.REQUEST_ID));
       // close requests - this method obtains a searcher in order to access 
its StatsCache
       req.close();
     }
@@ -210,7 +204,6 @@ public class DebugComponentTest extends SolrTestCaseJ4 {
       req = req("q", "test query", "distrib", "true");
       rb = new ResponseBuilder(req, new SolrQueryResponse(), components);
       rb.isDistrib = true;
-      addRequestId(rb, ANY_RID);
 
       // expecting the same results with debugQuery=true or debug=track
       if (random().nextBoolean()) {
@@ -224,15 +217,13 @@ public class DebugComponentTest extends SolrTestCaseJ4 {
         rb.setDebugResults(random().nextBoolean());
       }
       component.prepare(rb);
-      ensureTrackRecordsRid(rb, ANY_RID);
     }
 
-    req = req("q", "test query", "distrib", "true", CommonParams.REQUEST_ID, 
"123");
+    req = req("q", "test query", "distrib", "true");
     rb = new ResponseBuilder(req, new SolrQueryResponse(), components);
     rb.isDistrib = true;
     rb.setDebug(true);
     component.prepare(rb);
-    ensureTrackRecordsRid(rb, "123");
   }
 
   //
@@ -285,21 +276,8 @@ public class DebugComponentTest extends SolrTestCaseJ4 {
         "//str[@name='parsedquery'][contains(.,'3.0')]");
   }
 
-  @SuppressWarnings("unchecked")
-  private void ensureTrackRecordsRid(ResponseBuilder rb, String expectedRid) {
-    final String rid =
-        (String) ((NamedList<Object>) 
rb.getDebugInfo().get("track")).get(CommonParams.REQUEST_ID);
-    assertEquals("Expecting " + expectedRid + " but found " + rid, 
expectedRid, rid);
-  }
-
-  private void addRequestId(ResponseBuilder rb, String requestId) {
-    ModifiableSolrParams params = new ModifiableSolrParams(rb.req.getParams());
-    params.add(CommonParams.REQUEST_ID, requestId);
-    rb.req.setParams(params);
-  }
-
   @Test
-  public void testDistributedStageResolution() throws IOException {
+  public void testDistributedStageResolution() {
     final DebugComponent debugComponent = new DebugComponent();
     assertEquals(
         "PARSE_QUERY", 
debugComponent.getDistributedStageName(ResponseBuilder.STAGE_PARSE_QUERY));
diff --git 
a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
 
b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
index 75bed7e1907..e32da54aacc 100644
--- 
a/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
+++ 
b/solr/core/src/test/org/apache/solr/handler/component/DistributedDebugComponentTest.java
@@ -121,7 +121,6 @@ public class DistributedDebugComponentTest extends 
SolrJettyTestBase {
     QueryResponse response = collection1.query(query);
     NamedList<Object> track = (NamedList<Object>) 
response.getDebugMap().get("track");
     assertNotNull(track);
-    assertNotNull(track.get("rid"));
     assertNotNull(track.get("EXECUTE_QUERY"));
     assertNotNull(((NamedList<Object>) 
track.get("EXECUTE_QUERY")).get(shard1));
     assertNotNull(((NamedList<Object>) 
track.get("EXECUTE_QUERY")).get(shard2));
diff --git 
a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java 
b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
index 0387038aa84..052d0104bff 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
@@ -277,26 +277,6 @@ public interface CommonParams {
    */
   String COST = "cost";
 
-  /**
-   * Request ID parameter added to all distributed queries (that do not opt 
out)
-   *
-   * @see #DISABLE_REQUEST_ID
-   * @deprecated this was replaced by the auto-generated trace ids
-   */
-  @Deprecated(since = "9.4")
-  String REQUEST_ID = "rid";
-
-  /**
-   * An opt-out flag to prevent the addition of {@link #REQUEST_ID} tracing on 
distributed queries
-   *
-   * <p>Defaults to 'false' if not specified.
-   *
-   * @see #REQUEST_ID
-   * @deprecated this was replaced by the auto-generated trace ids
-   */
-  @Deprecated(since = "9.4")
-  String DISABLE_REQUEST_ID = "disableRequestId";
-
   /**
    * Parameter to control the distributed term statistics request for current 
query when distributed
    * IDF is enabled in solrconfig
diff --git a/solr/solrj/src/resources/EnvToSyspropMappings.properties 
b/solr/solrj/src/resources/EnvToSyspropMappings.properties
index 7fd76588b20..7571f2968d3 100644
--- a/solr/solrj/src/resources/EnvToSyspropMappings.properties
+++ b/solr/solrj/src/resources/EnvToSyspropMappings.properties
@@ -7,7 +7,6 @@
 AWS_PROFILE=aws.profile
 SOLR_ALWAYS_ON_TRACE_ID=solr.alwaysOnTraceId
 SOLR_AUTH_JWT_ALLOW_OUTBOUND_HTTP=solr.auth.jwt.allowOutboundHttp
-SOLR_DISABLE_REQUEST_ID=solr.disableRequestId
 SOLR_HIDDEN_SYS_PROPS=solr.hiddenSysProps
 SOLR_HOME=solr.solr.home
 SOLR_HOST_ADVERTISE=host

Reply via email to