You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2024/10/30 03:34:23 UTC
(solr) branch branch_9x updated (cae9f7c16f4 -> e9e034154a6)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
from cae9f7c16f4 SOLR-17515: Always init Http2SolrClient authStore (#2802)
new 93ac7d4456e SOLR-17485 Remove CheckLoggingConfiguration; unnecessary (#2763)
new fbcf6b3ecb2 SOLR-11191: SolrIndexSplitter: Routing child docs by _root_ when available (#2799)
new e9e034154a6 SOLR-16976: Remove log4j-jul jar and use Slf4j bridge for JUL (#2703)
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
solr/CHANGES.txt | 5 +
solr/bin/solr | 3 +-
solr/bin/solr.cmd | 2 +-
.../org/apache/solr/servlet/BaseSolrFilter.java | 31 ----
.../org/apache/solr/servlet/BaseSolrServlet.java | 32 ----
.../solr/servlet/CheckLoggingConfiguration.java | 37 ----
.../apache/solr/servlet/LoadAdminUiServlet.java | 11 +-
.../org/apache/solr/servlet/RedirectServlet.java | 3 +-
.../java/org/apache/solr/servlet/ServletUtils.java | 96 ++++------
.../apache/solr/servlet/SolrDispatchFilter.java | 32 ++--
.../org/apache/solr/update/SolrIndexSplitter.java | 15 +-
.../solr/configsets/cloud-minimal/conf/schema.xml | 2 +
.../test/org/apache/solr/cloud/SplitShardTest.java | 72 ++++++--
.../apache/solr/update/SolrIndexSplitterTest.java | 131 +++++++++++++-
solr/licenses/log4j-jul-2.21.0.jar.sha1 | 1 -
solr/licenses/log4j-jul-LICENSE-ASL.txt | 201 ---------------------
solr/licenses/log4j-jul-NOTICE.txt | 17 --
solr/packaging/test/test_start_solr.bats | 19 +-
solr/server/build.gradle | 1 -
solr/server/etc/jetty.xml | 2 +
.../pages/collection-management.adoc | 1 +
.../modules/deployment-guide/pages/node-roles.adoc | 2 +-
.../pages/solrcloud-shards-indexing.adoc | 2 +-
.../pages/indexing-nested-documents.adoc | 6 +-
versions.lock | 3 +-
25 files changed, 291 insertions(+), 436 deletions(-)
delete mode 100644 solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java
delete mode 100644 solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java
delete mode 100644 solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java
delete mode 100644 solr/licenses/log4j-jul-2.21.0.jar.sha1
delete mode 100644 solr/licenses/log4j-jul-LICENSE-ASL.txt
delete mode 100644 solr/licenses/log4j-jul-NOTICE.txt
(solr) 02/03: SOLR-11191: SolrIndexSplitter: Routing child docs by _root_ when available (#2799)
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit fbcf6b3ecb2d20d584fbf6d7290974f9b41c191f
Author: Zack Kendall <za...@gmail.com>
AuthorDate: Tue Oct 29 21:29:41 2024 -0400
SOLR-11191: SolrIndexSplitter: Routing child docs by _root_ when available (#2799)
Splitting shards now supports child / nested docs. Works based on splitting based on the _root_ field.
Co-authored-by: zkendall <zk...@axon.com>
(cherry picked from commit e377ebbdaff5ae784b3f4e4315afa4d6705d1d71)
---
solr/CHANGES.txt | 2 +
.../org/apache/solr/update/SolrIndexSplitter.java | 15 ++-
.../solr/configsets/cloud-minimal/conf/schema.xml | 2 +
.../test/org/apache/solr/cloud/SplitShardTest.java | 72 ++++++++---
.../apache/solr/update/SolrIndexSplitterTest.java | 131 ++++++++++++++++++++-
.../pages/collection-management.adoc | 1 +
.../modules/deployment-guide/pages/node-roles.adoc | 2 +-
.../pages/solrcloud-shards-indexing.adoc | 2 +-
.../pages/indexing-nested-documents.adoc | 6 +-
9 files changed, 209 insertions(+), 24 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7c5e0b99b24..6a5eb63c1a9 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -85,6 +85,8 @@ Bug Fixes
* SOLR-17529: Clean up error message in PostTool when you attempt to post to a basic auth secured Solr. (Eric Pugh)
+* SOLR-11191: Splitting shards now routes child-docs with their _root_ field when available so they maintain parent relationship. (Zack Kendall)
+
Dependency Upgrades
---------------------
(No changes)
diff --git a/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java b/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
index 61ba505ddd5..fa12d7b51d4 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrIndexSplitter.java
@@ -69,6 +69,7 @@ import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.IndexFetcher;
import org.apache.solr.handler.SnapShooter;
+import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.BitsFilteredPostingsEnum;
import org.apache.solr.search.SolrIndexSearcher;
@@ -125,17 +126,29 @@ public class SolrIndexSplitter {
numPieces = cmd.ranges.size();
rangesArr = cmd.ranges.toArray(new DocRouter.Range[0]);
}
+
if (cmd.routeFieldName == null) {
- field = searcher.getSchema().getUniqueKeyField();
+ // To support routing child documents, use the root field if it exists (which would be
+ // populated with unique field), otherwise use the unique key field
+ if (searcher.getSchema().isUsableForChildDocs()) {
+ field = searcher.getSchema().getField(IndexSchema.ROOT_FIELD_NAME);
+ } else {
+ field = searcher.getSchema().getUniqueKeyField();
+ }
} else {
+ // Custom routing
+ // If child docs are used, users must ensure that the whole nested document tree has a
+ // consistent routeField value
field = searcher.getSchema().getField(cmd.routeFieldName);
}
+
if (cmd.splitKey == null) {
splitKey = null;
} else {
checkRouterSupportsSplitKey(hashRouter, cmd.splitKey);
splitKey = ((CompositeIdRouter) hashRouter).getRouteKeyNoSuffix(cmd.splitKey);
}
+
if (cmd.cores == null) {
this.splitMethod = SplitMethod.REWRITE;
} else {
diff --git a/solr/core/src/test-files/solr/configsets/cloud-minimal/conf/schema.xml b/solr/core/src/test-files/solr/configsets/cloud-minimal/conf/schema.xml
index fc23706512e..3c25f27405a 100644
--- a/solr/core/src/test-files/solr/configsets/cloud-minimal/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/cloud-minimal/conf/schema.xml
@@ -19,10 +19,12 @@
<fieldType name="string" class="solr.StrField"/>
<fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0" uninvertible="true"/>
<fieldType name="long" class="${solr.tests.LongFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0" uninvertible="true"/>
+ <fieldType name="_nest_path_" class="solr.NestPathField"/>
<dynamicField name="*" type="string" indexed="true" stored="true"/>
<!-- for versioning -->
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="_root_" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
+ <field name="_nest_path_" type="_nest_path_"/>`
<field name="id" type="string" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java b/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java
index dddc089ce55..e69c9a08529 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java
@@ -21,6 +21,7 @@ import static org.hamcrest.core.StringContains.containsString;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -36,11 +37,14 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
@@ -89,16 +93,7 @@ public class SplitShardTest extends SolrCloudTestCase {
.setNumSubShards(5)
.setShardName("shard1");
splitShard.process(cluster.getSolrClient());
- waitForState(
- "Timed out waiting for sub shards to be active. Number of active shards="
- + cluster
- .getSolrClient()
- .getClusterState()
- .getCollection(COLLECTION_NAME)
- .getActiveSlices()
- .size(),
- COLLECTION_NAME,
- activeClusterShape(6, 7));
+ waitForState("Waiting for 6 shards after split", COLLECTION_NAME, activeClusterShape(6, 7));
try {
splitShard =
@@ -154,15 +149,7 @@ public class SplitShardTest extends SolrCloudTestCase {
CollectionAdminRequest.splitShard(collectionName).setSplitFuzz(0.5f).setShardName("shard1");
splitShard.process(cluster.getSolrClient());
waitForState(
- "Timed out waiting for sub shards to be active. Number of active shards="
- + cluster
- .getSolrClient()
- .getClusterState()
- .getCollection(collectionName)
- .getActiveSlices()
- .size(),
- collectionName,
- activeClusterShape(3, 4));
+ "Waiting for 3 active shards after split", collectionName, activeClusterShape(3, 4));
DocCollection coll = cluster.getSolrClient().getClusterState().getCollection(collectionName);
Slice s1_0 = coll.getSlice("shard1_0");
Slice s1_1 = coll.getSlice("shard1_1");
@@ -175,6 +162,53 @@ public class SplitShardTest extends SolrCloudTestCase {
assertEquals("wrong range in s1_1", expected1, delta1);
}
+ @Test
+ public void testWithChildDocuments() throws Exception {
+ CloudSolrClient solrClient = cluster.getSolrClient();
+ CollectionAdminRequest.createCollection(COLLECTION_NAME, "conf", 1, 1).process(solrClient);
+
+ cluster.waitForActiveCollection(COLLECTION_NAME, 1, 1);
+
+ List<SolrInputDocument> inputDocs = new ArrayList<>();
+ for (int idx = 0; idx < 20; ) { // 10 parents + 10 children
+ SolrInputDocument parent = new SolrInputDocument();
+ parent.addField("id", ++idx);
+ parent.addField("type_s", "parent");
+
+ // Child has different ID, so could be routed differently if used for routing.
+ SolrInputDocument child = new SolrInputDocument();
+ child.addField("id", ++idx);
+ child.addField("expected_parent_s", parent.getField("id"));
+
+ parent.addField("myChild", List.of(child));
+
+ inputDocs.add(parent);
+ }
+ solrClient.add(COLLECTION_NAME, inputDocs);
+
+ CollectionAdminRequest.SplitShard splitShard =
+ CollectionAdminRequest.splitShard(COLLECTION_NAME)
+ .setNumSubShards(2)
+ .setShardName("shard1");
+ splitShard.setWaitForFinalState(true);
+ splitShard.process(solrClient);
+ CollectionAdminRequest.deleteShard(COLLECTION_NAME, "shard1").process(solrClient);
+ waitForState(
+ "Waiting for 2 active shards after split", COLLECTION_NAME, activeClusterShape(2, 2));
+
+ QueryRequest req =
+ new QueryRequest(new SolrQuery("type_s:parent").setFields("*", "[child]", "[shard]"));
+ QueryResponse rsp = req.process(solrClient, COLLECTION_NAME);
+ assertEquals(10, rsp.getResults().getNumFound());
+ for (SolrDocument doc : rsp.getResults()) {
+ @SuppressWarnings("unchecked")
+ List<SolrDocument> children = (List<SolrDocument>) doc.get("myChild");
+ assertEquals("only 1 child per parent", 1, children.size());
+ SolrDocument child = children.get(0);
+ assertEquals("parent-child match", doc.get("id"), child.get("expected_parent_s"));
+ }
+ }
+
private CloudSolrClient createCollection(String collectionName, int repFactor) throws Exception {
CollectionAdminRequest.createCollection(collectionName, "conf", 1, repFactor)
diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
index 2796233ea0b..78906e9b8e0 100644
--- a/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexSplitterTest.java
@@ -28,6 +28,7 @@ import org.apache.lucene.store.Directory;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.CompositeIdRouter;
import org.apache.solr.common.cloud.DocRouter;
import org.apache.solr.common.cloud.PlainIdRouter;
@@ -485,19 +486,147 @@ public class SolrIndexSplitterTest extends SolrTestCaseJ4 {
}
}
+ @Test
+ public void testSplitWithChildDocs() throws Exception {
+ doTestSplitWithChildDocs(SolrIndexSplitter.SplitMethod.REWRITE);
+ }
+
+ @Test
+ public void testSplitWithChildDocsLink() throws Exception {
+ doTestSplitWithChildDocs(SolrIndexSplitter.SplitMethod.LINK);
+ }
+
+ public void doTestSplitWithChildDocs(SolrIndexSplitter.SplitMethod splitMethod) throws Exception {
+ // Overall test/split pattern copied from doTestSplitByCores
+ File indexDir = createTempDir().toFile();
+
+ CompositeIdRouter r1 = new CompositeIdRouter();
+ String routeKeyBase = "sea-line!";
+
+ List<DocRouter.Range> twoRanges = r1.partitionRange(2, r1.keyHashRange(routeKeyBase));
+
+ // Insert other doc for contrast
+ String otherDocId = routeKeyBase + "6"; // Will hash into first range
+ assertU(adoc("id", otherDocId));
+
+ // Insert child doc
+ String parentId = routeKeyBase + "1"; // Will hash into second range
+ String childId = routeKeyBase + "5"; // Will hash into first range
+ SolrInputDocument doc =
+ sdoc("id", parentId, "myChild", sdocs(sdoc("id", childId, "child_s", "child")));
+ assertU(adoc(doc));
+
+ assertU(commit());
+ assertJQ(req("q", "*:*"), "/response/numFound==3");
+
+ // Able to query child.
+ assertJQ(
+ req("q", "id:" + parentId, "fl", "*, [child]"),
+ "/response/numFound==1",
+ "/response/docs/[0]/myChild/[0]/id=='" + childId + "'",
+ "/response/docs/[0]/myChild/[0]/_root_=='"
+ + parentId
+ + "'" // Child has parent root to route with
+ );
+
+ SolrCore core1 = null, core2 = null;
+ try {
+ core1 =
+ h.getCoreContainer()
+ .create(
+ "split1",
+ Map.of("dataDir", indexDir1.getAbsolutePath(), "configSet", "cloud-minimal"));
+ core2 =
+ h.getCoreContainer()
+ .create(
+ "split2",
+ Map.of("dataDir", indexDir2.getAbsolutePath(), "configSet", "cloud-minimal"));
+
+ LocalSolrQueryRequest request = null;
+ try {
+ request = lrf.makeRequest("q", "dummy");
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ SplitIndexCommand command =
+ new SplitIndexCommand(
+ request,
+ rsp,
+ null,
+ List.of(core1, core2),
+ twoRanges,
+ new CompositeIdRouter(),
+ null,
+ null,
+ splitMethod);
+ doSplit(command);
+ } finally {
+ if (request != null) request.close();
+ }
+ @SuppressWarnings("resource")
+ final EmbeddedSolrServer server1 = new EmbeddedSolrServer(h.getCoreContainer(), "split1");
+ @SuppressWarnings("resource")
+ final EmbeddedSolrServer server2 = new EmbeddedSolrServer(h.getCoreContainer(), "split2");
+ server1.commit(true, true);
+ server2.commit(true, true);
+ assertEquals(
+ "should be 2 docs in index2",
+ 2,
+ server2.query(new SolrQuery("*:*")).getResults().getNumFound());
+ assertEquals(
+ "parent doc should be in index2",
+ 1,
+ server2.query(new SolrQuery("id:" + parentId)).getResults().getNumFound());
+ assertEquals(
+ "child doc should be in index2",
+ 1,
+ server2.query(new SolrQuery("id:" + childId)).getResults().getNumFound());
+ assertEquals(
+ "other doc should be in index1",
+ 1,
+ server1.query(new SolrQuery("id:" + otherDocId)).getResults().getNumFound());
+ } finally {
+ h.getCoreContainer().unload("split2");
+ h.getCoreContainer().unload("split1");
+ }
+ }
+
+ /** Utility method to find Ids that hash into which ranges. Uncomment @Test to print. */
+ // @Test
+ public void printCompositeHashSandbox() {
+ CompositeIdRouter r1 = new CompositeIdRouter();
+ String routeBase = "sea-line!";
+ DocRouter.Range routeBaseRange = r1.keyHashRange(routeBase);
+ List<DocRouter.Range> twoRanges = r1.partitionRange(2, routeBaseRange);
+ System.out.println("splitKeyRange = " + twoRanges);
+
+ // Hash some values and print which range they fall into
+ for (int i = 0; i < 10; i++) {
+ String key = routeBase + i;
+ int hash = r1.sliceHash(key, null, null, null);
+ boolean inA = twoRanges.get(0).includes(hash);
+ boolean inB = twoRanges.get(1).includes(hash);
+
+ // Print which range the key is in
+ System.out.println(key + " in " + (inA ? twoRanges.get(0) : twoRanges.get(1)));
+ }
+ }
+
+ /** Creates a range encompassing the two ids, then splits it in two. Uses PlainIdRouter */
private List<DocRouter.Range> getRanges(String id1, String id2) {
// find minHash/maxHash hash ranges
byte[] bytes = id1.getBytes(StandardCharsets.UTF_8);
int minHash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
bytes = id2.getBytes(StandardCharsets.UTF_8);
int maxHash = Hash.murmurhash3_x86_32(bytes, 0, bytes.length, 0);
-
if (minHash > maxHash) {
int temp = maxHash;
maxHash = minHash;
minHash = temp;
}
+ if (maxHash - minHash < 2) {
+ throw new RuntimeException("The range is too small to split");
+ }
+
PlainIdRouter router = new PlainIdRouter();
DocRouter.Range fullRange = new DocRouter.Range(minHash, maxHash);
return router.partitionRange(2, fullRange);
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/collection-management.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/collection-management.adoc
index 62f43f6d54e..27517115afb 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/collection-management.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/collection-management.adoc
@@ -228,6 +228,7 @@ When such a collection is deleted, its autocreated configset will be deleted by
+
If this parameter is specified, the router will look at the value of the field in an input document to compute the hash and identify a shard instead of looking at the `uniqueKey` field.
If the field specified is null in the document, the document will be rejected.
+For nested documents, the route field must match among all the documents in the hierarchy.
+
Please note that xref:configuration-guide:realtime-get.adoc[] or retrieval by document ID would also require the parameter `\_route_` (or `shard.keys`) to avoid a distributed search.
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/node-roles.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/node-roles.adoc
index a261d23e70c..07dab503bdd 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/node-roles.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/node-roles.adoc
@@ -73,7 +73,7 @@ A node with this role can perform duties of an overseer node (unless mode is `di
A node with this role can act as if it has replicas of all collections in the cluster when a query is performed. The workflow is as follows
-If the cluster has collections with very large no:of shards, performing distributed requests in your _`data node`_ will lead to
+If the cluster has collections with very large no:of shards, performing distributed requests in your _data node_ will lead to
* large heap utilization
* frequent GC pauses
diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solrcloud-shards-indexing.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solrcloud-shards-indexing.adoc
index cbc20ca9aa2..fb5ff6f1606 100644
--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solrcloud-shards-indexing.adoc
+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solrcloud-shards-indexing.adoc
@@ -146,7 +146,7 @@ At query time, you include the prefix(es) along with the number of bits into you
If you do not want to influence how documents are stored, you don't need to specify a prefix in your document ID.
If you created the collection and defined the "implicit" router at the time of creation, you can additionally define a `router.field` parameter to use a field from each document to identify a shard where the document belongs.
-If the field specified is missing in the document, however, the document will be rejected.
+If the field specified is missing in the document, then the document will be rejected.
You could also use the `\_route_` parameter to name a specific shard.
== Shard Splitting
diff --git a/solr/solr-ref-guide/modules/indexing-guide/pages/indexing-nested-documents.adoc b/solr/solr-ref-guide/modules/indexing-guide/pages/indexing-nested-documents.adoc
index 939f8f2adc5..fedb60d7e3e 100644
--- a/solr/solr-ref-guide/modules/indexing-guide/pages/indexing-nested-documents.adoc
+++ b/solr/solr-ref-guide/modules/indexing-guide/pages/indexing-nested-documents.adoc
@@ -283,7 +283,7 @@ This makes it much easier to apply
xref:partial-document-updates.adoc#updating-child-documents[atomic updates] to individual child documents.
====
-== Maintaining Integrity with Updates and Deletes
+== Maintaining Integrity with Updates, Deletes, and Shard Splits
Nested document trees can be modified with
xref:partial-document-updates.adoc#atomic-updates[atomic updates] to
@@ -304,6 +304,10 @@ Instead, use delete-by-query (most efficient) or xref:partial-document-updates.a
If you use Solr's delete-by-query APIs, you *MUST* be careful to ensure that any deletion query is structured to ensure no descendent children remain of any documents that are being deleted.
*_Doing otherwise will violate integrity assumptions that Solr expects._*
+When xref:deployment-guide:shard-management.adoc#splitshard[splitting shards], child documents get transmitted and routed independently.
+If you use the default `router.field`, this is handled correctly for you.
+If your collection has a custom `router.field`, then you must ensure that all documents in a hierarchy have the same value for that field.
+
== Indexing Anonymous Children
Although not recommended, it is also possible to index child documents "anonymously":
(solr) 03/03: SOLR-16976: Remove log4j-jul jar and use Slf4j bridge for JUL (#2703)
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit e9e034154a608bcd937575f3cb23f86e230e7df9
Author: szhou1998 <15...@users.noreply.github.com>
AuthorDate: Tue Oct 29 21:38:08 2024 -0400
SOLR-16976: Remove log4j-jul jar and use Slf4j bridge for JUL (#2703)
Remove log4j-jul jar and use slf4j bridge for JUL to prevent exception from being logged when remote JMX
is enabled .
Updated jetty.xml to initialize the bridge super early.
Co-authored-by: Eric Pugh <ep...@opensourceconnections.com>
Co-authored-by: David Smiley <ds...@apache.org>
(cherry picked from commit dbf1c50a67b2e23758ae2381745898f191f0bd47)
---
solr/CHANGES.txt | 3 +
solr/bin/solr | 3 +-
solr/bin/solr.cmd | 2 +-
solr/licenses/log4j-jul-2.21.0.jar.sha1 | 1 -
solr/licenses/log4j-jul-LICENSE-ASL.txt | 201 -------------------------------
solr/licenses/log4j-jul-NOTICE.txt | 17 ---
solr/packaging/test/test_start_solr.bats | 19 ++-
solr/server/build.gradle | 1 -
solr/server/etc/jetty.xml | 2 +
versions.lock | 3 +-
10 files changed, 23 insertions(+), 229 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6a5eb63c1a9..a6bdde2f0fc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -87,6 +87,9 @@ Bug Fixes
* SOLR-11191: Splitting shards now routes child-docs with their _root_ field when available so they maintain parent relationship. (Zack Kendall)
+* SOLR-16976: Remove log4j-jul jar and use slf4j bridge for JUL to prevent exception from being logged when remote JMX
+ is enabled (Shawn Heisey, Stephen Zhou, Eric Pugh, Christine Poerschke, David Smiley)
+
Dependency Upgrades
---------------------
(No changes)
diff --git a/solr/bin/solr b/solr/bin/solr
index dbc23b18ff8..0509f465173 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -1071,8 +1071,7 @@ if [ "${SOLR_HOME:0:${#EXAMPLE_DIR}}" = "$EXAMPLE_DIR" ]; then
SOLR_LOGS_DIR="$SOLR_HOME/../logs"
fi
-# Set the logging manager by default, so that Lucene JUL logs are included with Solr logs.
-LOG4J_CONFIG=("-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager")
+LOG4J_CONFIG=()
if [ -n "${LOG4J_PROPS:-}" ]; then
LOG4J_CONFIG+=("-Dlog4j.configurationFile=$LOG4J_PROPS")
fi
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 67c1f194061..9d56c9aa872 100755
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -1187,7 +1187,7 @@ IF "%SOLR_SSL_ENABLED%"=="true" (
set SOLR_LOGS_DIR_QUOTED="%SOLR_LOGS_DIR%"
set SOLR_DATA_HOME_QUOTED="%SOLR_DATA_HOME%"
-set "START_OPTS=%START_OPTS% -Dsolr.log.dir=%SOLR_LOGS_DIR_QUOTED% -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"
+set "START_OPTS=%START_OPTS% -Dsolr.log.dir=%SOLR_LOGS_DIR_QUOTED%"
IF NOT "%SOLR_DATA_HOME%"=="" set "START_OPTS=%START_OPTS% -Dsolr.data.home=%SOLR_DATA_HOME_QUOTED%"
IF NOT DEFINED LOG4J_CONFIG set "LOG4J_CONFIG=%SOLR_SERVER_DIR%\resources\log4j2.xml"
diff --git a/solr/licenses/log4j-jul-2.21.0.jar.sha1 b/solr/licenses/log4j-jul-2.21.0.jar.sha1
deleted file mode 100644
index 89f7c940953..00000000000
--- a/solr/licenses/log4j-jul-2.21.0.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-f0da61113f4a47654677e6a98b1e13ca7de2483d
diff --git a/solr/licenses/log4j-jul-LICENSE-ASL.txt b/solr/licenses/log4j-jul-LICENSE-ASL.txt
deleted file mode 100644
index f49a4e16e68..00000000000
--- a/solr/licenses/log4j-jul-LICENSE-ASL.txt
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
\ No newline at end of file
diff --git a/solr/licenses/log4j-jul-NOTICE.txt b/solr/licenses/log4j-jul-NOTICE.txt
deleted file mode 100644
index ebba5ac0018..00000000000
--- a/solr/licenses/log4j-jul-NOTICE.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-Apache Log4j
-Copyright 1999-2017 Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-ResolverUtil.java
-Copyright 2005-2006 Tim Fennell
-
-Dumbster SMTP test server
-Copyright 2004 Jason Paul Kitchen
-
-TypeUtil.java
-Copyright 2002-2012 Ramnivas Laddad, Juergen Hoeller, Chris Beams
-
-picocli (http://picocli.info)
-Copyright 2017 Remko Popma
\ No newline at end of file
diff --git a/solr/packaging/test/test_start_solr.bats b/solr/packaging/test/test_start_solr.bats
index 6c82dc117cf..f6ca16d5fbf 100644
--- a/solr/packaging/test/test_start_solr.bats
+++ b/solr/packaging/test/test_start_solr.bats
@@ -43,7 +43,7 @@ teardown() {
solr start -p ${SOLR2_PORT}
solr assert --started http://localhost:${SOLR_PORT}/solr --timeout 5000
solr assert --started http://localhost:${SOLR2_PORT}/solr --timeout 5000
-
+
run solr stop -p ${SOLR2_PORT}
solr assert --not-started http://localhost:${SOLR2_PORT}/solr --timeout 5000
solr assert --started http://localhost:${SOLR_PORT}/solr --timeout 5000
@@ -77,13 +77,24 @@ teardown() {
@test "check stop command doesn't hang" {
# for start/stop/restart we parse the args separate from picking the command
# which means you don't get an error message for passing a start arg, like --jvm-opts to a stop commmand.
-
+
# Set a timeout duration (in seconds)
TIMEOUT_DURATION=2
# make sure that passing a non flag option (i.e --jvm-opts "blah") doesn't hang the stop command.
run timeout $TIMEOUT_DURATION solr stop --jvm-opts
-
+
assert_output --partial "ERROR: JVM options are required when using the --jvm-opts option!"
-
+
+}
+
+@test "SOLR-16976 solr starts with remote JMX enabled" {
+ export ENABLE_REMOTE_JMX_OPTS=true
+ export RMI_PORT=65535 # need to make sure we don't exceed port range so hard code it
+
+ solr start
+ solr assert --started http://localhost:${SOLR_PORT} --timeout 5000
+
+ run cat ${SOLR_LOGS_DIR}/solr-${SOLR_PORT}-console.log
+ refute_output --partial 'Exception'
}
diff --git a/solr/server/build.gradle b/solr/server/build.gradle
index d0b722d63f6..93b1196b95b 100644
--- a/solr/server/build.gradle
+++ b/solr/server/build.gradle
@@ -69,7 +69,6 @@ dependencies {
libExt 'org.apache.logging.log4j:log4j-1.2-api'
libExt 'org.apache.logging.log4j:log4j-api'
libExt 'org.apache.logging.log4j:log4j-core'
- libExt 'org.apache.logging.log4j:log4j-jul'
libExt 'org.apache.logging.log4j:log4j-layout-template-json'
libExt 'org.apache.logging.log4j:log4j-slf4j2-impl'
libExt 'org.apache.logging.log4j:log4j-web'
diff --git a/solr/server/etc/jetty.xml b/solr/server/etc/jetty.xml
index ee3d3f0246f..282de87536f 100644
--- a/solr/server/etc/jetty.xml
+++ b/solr/server/etc/jetty.xml
@@ -47,6 +47,8 @@
<Set name="detailedDump">false</Set>
</Get>
+ <Call class="org.slf4j.bridge.SLF4JBridgeHandler" name="removeHandlersForRootLogger"/>
+ <Call class="org.slf4j.bridge.SLF4JBridgeHandler" name="install"/>
<!-- =========================================================== -->
<!-- Http Configuration. -->
diff --git a/versions.lock b/versions.lock
index b9c1edce821..ef3cf0216ff 100644
--- a/versions.lock
+++ b/versions.lock
@@ -236,9 +236,8 @@ org.apache.kerby:kerby-config:2.0.3 (4 constraints: 593132bc)
org.apache.kerby:kerby-pkix:2.0.3 (1 constraints: 740b03e5)
org.apache.kerby:kerby-util:2.0.3 (2 constraints: 6b1837b7)
org.apache.logging.log4j:log4j-1.2-api:2.21.0 (1 constraints: 3705363b)
-org.apache.logging.log4j:log4j-api:2.21.0 (10 constraints: f07d3453)
+org.apache.logging.log4j:log4j-api:2.21.0 (9 constraints: 976ff7be)
org.apache.logging.log4j:log4j-core:2.21.0 (5 constraints: 5f510091)
-org.apache.logging.log4j:log4j-jul:2.21.0 (1 constraints: 3705363b)
org.apache.logging.log4j:log4j-layout-template-json:2.21.0 (1 constraints: 3705363b)
org.apache.logging.log4j:log4j-slf4j2-impl:2.21.0 (1 constraints: 3705363b)
org.apache.logging.log4j:log4j-web:2.21.0 (1 constraints: 3705363b)
(solr) 01/03: SOLR-17485 Remove CheckLoggingConfiguration; unnecessary (#2763)
Posted by ds...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 93ac7d4456e36ebaf386820dc075248b14764940
Author: David Smiley <ds...@apache.org>
AuthorDate: Tue Oct 29 21:26:05 2024 -0400
SOLR-17485 Remove CheckLoggingConfiguration; unnecessary (#2763)
A refactoring, and removing needless CheckLoggingConfiguration.
Misc changes:
* Extend HttpFilter etc.; remove needless subclasses. Thus don't need to cast HttpServletRequest.
* remove no-op needless destroy(); same as super
* Move excludePath check to very first thing
* rename doFilter(...retry) to doFilterRetry
* move closeShield to before doFilterRetry so it doesn't have to know about retry, simplifying things.
* no longer have leading underscore param names since no longer have variable masking
(cherry picked from commit 8f18729f97e897f3755421c65b4b539fbc871746)
---
.../org/apache/solr/servlet/BaseSolrFilter.java | 31 -------
.../org/apache/solr/servlet/BaseSolrServlet.java | 32 --------
.../solr/servlet/CheckLoggingConfiguration.java | 37 ---------
.../apache/solr/servlet/LoadAdminUiServlet.java | 11 +--
.../org/apache/solr/servlet/RedirectServlet.java | 3 +-
.../java/org/apache/solr/servlet/ServletUtils.java | 96 +++++++++-------------
.../apache/solr/servlet/SolrDispatchFilter.java | 32 +++-----
7 files changed, 59 insertions(+), 183 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java b/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java
deleted file mode 100644
index d16d722447d..00000000000
--- a/solr/core/src/java/org/apache/solr/servlet/BaseSolrFilter.java
+++ /dev/null
@@ -1,31 +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.servlet;
-
-import javax.servlet.Filter;
-
-/**
- * All Solr filters available to the user's webapp should extend this class and not just implement
- * {@link Filter}. This class ensures that the logging configuration is correct before any Solr
- * specific code is executed.
- */
-abstract class BaseSolrFilter implements Filter {
-
- static {
- CheckLoggingConfiguration.check();
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java b/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java
deleted file mode 100644
index 85aca08cd86..00000000000
--- a/solr/core/src/java/org/apache/solr/servlet/BaseSolrServlet.java
+++ /dev/null
@@ -1,32 +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.servlet;
-
-import javax.servlet.http.HttpServlet;
-
-/**
- * All Solr servlets available to the user's webapp should extend this class and not {@link
- * HttpServlet}. This class ensures that the logging configuration is correct before any Solr
- * specific code is executed.
- */
-@SuppressWarnings("serial")
-abstract class BaseSolrServlet extends HttpServlet {
-
- static {
- CheckLoggingConfiguration.check();
- }
-}
diff --git a/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java b/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java
deleted file mode 100644
index 70506dea12e..00000000000
--- a/solr/core/src/java/org/apache/solr/servlet/CheckLoggingConfiguration.java
+++ /dev/null
@@ -1,37 +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.servlet;
-
-import java.lang.invoke.MethodHandles;
-import org.slf4j.LoggerFactory;
-
-final class CheckLoggingConfiguration {
-
- static void check() {
- try {
- LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- } catch (NoClassDefFoundError e) {
- throw new NoClassDefFoundError(
- "Failed to initialize Apache Solr: "
- + "Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in "
- + "the jetty lib/ext directory. For other containers, the corresponding directory should be used. "
- + "For more information, see: https://cwiki.apache.org/confluence/display/solr/SolrLogging#SolrLogging-UsingtheexampleloggingsetupincontainersotherthanJetty");
- }
- }
-
- private CheckLoggingConfiguration() {}
-}
diff --git a/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java b/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
index 9da4bc84775..436906d3a69 100644
--- a/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
+++ b/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
@@ -25,6 +25,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.output.CloseShieldOutputStream;
@@ -36,7 +37,7 @@ import org.apache.solr.core.SolrCore;
*
* @since solr 4.0
*/
-public final class LoadAdminUiServlet extends BaseSolrServlet {
+public final class LoadAdminUiServlet extends HttpServlet {
// check system properties for whether or not admin UI is disabled, default is false
private static final boolean disabled =
@@ -45,16 +46,16 @@ public final class LoadAdminUiServlet extends BaseSolrServlet {
public static final String SYSPROP_CSP_CONNECT_SRC_URLS = "solr.ui.headers.csp.connect-src.urls";
@Override
- public void doGet(HttpServletRequest _request, HttpServletResponse _response) throws IOException {
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (disabled) {
- _response.sendError(
+ response.sendError(
404,
"Solr Admin UI is disabled. To enable it, change the default value of SOLR_ADMIN_UI_"
+ "ENABLED in bin/solr.in.sh or solr.in.cmd.");
return;
}
- HttpServletRequest request = ServletUtils.closeShield(_request, false);
- HttpServletResponse response = ServletUtils.closeShield(_response, false);
+ request = ServletUtils.closeShield(request);
+ response = ServletUtils.closeShield(response);
response.addHeader(
"X-Frame-Options", "DENY"); // security: SOLR-7966 - avoid clickjacking for admin interface
diff --git a/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java b/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
index a67e20831de..a0c11b15a04 100644
--- a/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
+++ b/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
@@ -19,11 +19,12 @@ package org.apache.solr.servlet;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** A Simple redirection servlet to help us deprecate old UI elements */
-public class RedirectServlet extends BaseSolrServlet {
+public class RedirectServlet extends HttpServlet {
static final String CONTEXT_KEY = "${context}";
diff --git a/solr/core/src/java/org/apache/solr/servlet/ServletUtils.java b/solr/core/src/java/org/apache/solr/servlet/ServletUtils.java
index c4da8e4d7b0..80234081971 100644
--- a/solr/core/src/java/org/apache/solr/servlet/ServletUtils.java
+++ b/solr/core/src/java/org/apache/solr/servlet/ServletUtils.java
@@ -76,78 +76,62 @@ public abstract class ServletUtils {
}
/**
- * Wrap the request's input stream with a close shield. If this is a retry, we will assume that
- * the stream has already been wrapped and do nothing.
+ * Wrap the request's input stream with a close shield.
*
* <p>Only the container should ever actually close the servlet output stream. This method
* possibly should be turned into a servlet filter
*
* @param request The request to wrap.
- * @param retry If this is an original request or a retry.
* @return A request object with an {@link InputStream} that will ignore calls to close.
*/
- public static HttpServletRequest closeShield(HttpServletRequest request, boolean retry) {
- if (!retry) {
- return new HttpServletRequestWrapper(request) {
-
- @Override
- public ServletInputStream getInputStream() throws IOException {
-
- return new ServletInputStreamWrapper(super.getInputStream()) {
- @Override
- public void close() {
- // even though we skip closes, we let local tests know not to close so that a full
- // understanding can take place
- assert !Thread.currentThread()
- .getStackTrace()[2]
- .getClassName()
- .matches("org\\.apache\\.(?:solr|lucene).*")
- : CLOSE_STREAM_MSG;
- this.stream = ClosedServletInputStream.CLOSED_SERVLET_INPUT_STREAM;
- }
- };
- }
- };
- } else {
- return request;
- }
+ public static HttpServletRequest closeShield(HttpServletRequest request) {
+ return new HttpServletRequestWrapper(request) {
+ @Override
+ public ServletInputStream getInputStream() throws IOException {
+ return new ServletInputStreamWrapper(super.getInputStream()) {
+ @Override
+ public void close() {
+ // even though we skip closes, we let local tests know not to close so that a full
+ // understanding can take place
+ assert !Thread.currentThread()
+ .getStackTrace()[2]
+ .getClassName()
+ .matches("org\\.apache\\.(?:solr|lucene).*")
+ : CLOSE_STREAM_MSG;
+ this.stream = ClosedServletInputStream.CLOSED_SERVLET_INPUT_STREAM;
+ }
+ };
+ }
+ };
}
/**
- * Wrap the response's output stream with a close shield. If this is a retry, we will assume that
- * the stream has already been wrapped and do nothing.
+ * Wrap the response's output stream with a close shield.
*
* <p>Only the container should ever actually close the servlet request stream.
*
* @param response The response to wrap.
- * @param retry If this response corresponds to an original request or a retry.
* @return A response object with an {@link OutputStream} that will ignore calls to close.
*/
- public static HttpServletResponse closeShield(HttpServletResponse response, boolean retry) {
- if (!retry) {
- return new HttpServletResponseWrapper(response) {
-
- @Override
- public ServletOutputStream getOutputStream() throws IOException {
-
- return new ServletOutputStreamWrapper(super.getOutputStream()) {
- @Override
- public void close() {
- // even though we skip closes, we let local tests know not to close so that a full
- // understanding can take place
- assert !Thread.currentThread()
- .getStackTrace()[2]
- .getClassName()
- .matches("org\\.apache\\.(?:solr|lucene).*")
- : CLOSE_STREAM_MSG;
- stream = ClosedServletOutputStream.CLOSED_SERVLET_OUTPUT_STREAM;
- }
- };
- }
- };
- } else {
- return response;
- }
+ public static HttpServletResponse closeShield(HttpServletResponse response) {
+ return new HttpServletResponseWrapper(response) {
+ @Override
+ public ServletOutputStream getOutputStream() throws IOException {
+ return new ServletOutputStreamWrapper(super.getOutputStream()) {
+ @Override
+ public void close() {
+ // even though we skip closes, we let local tests know not to close so that a full
+ // understanding can take place
+ assert !Thread.currentThread()
+ .getStackTrace()[2]
+ .getClassName()
+ .matches("org\\.apache\\.(?:solr|lucene).*")
+ : CLOSE_STREAM_MSG;
+ stream = ClosedServletOutputStream.CLOSED_SERVLET_OUTPUT_STREAM;
+ }
+ };
+ }
+ };
}
static boolean excludedPath(
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 bd408f886cf..cfdac952858 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -36,9 +36,8 @@ import java.util.regex.Pattern;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.client.HttpClient;
@@ -70,7 +69,7 @@ import org.slf4j.LoggerFactory;
// servlets that are more focused in scope. This should become possible now that we have a
// ServletContextListener for startup/shutdown of CoreContainer that sets up a service from which
// things like CoreContainer can be requested. (or better yet injected)
-public class SolrDispatchFilter extends BaseSolrFilter implements PathExcluder {
+public class SolrDispatchFilter extends HttpFilter implements PathExcluder {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String ATTR_TRACING_SPAN = Span.class.getName();
public static final String ATTR_TRACING_TRACER = Tracer.class.getName();
@@ -163,38 +162,29 @@ public class SolrDispatchFilter extends BaseSolrFilter implements PathExcluder {
return containerProvider.getCoreContainer();
}
- @Override
- public void destroy() {
- // CoreService shuts itself down as a ContextListener. The filter does not own anything with a
- // lifecycle anymore! Yay!
- }
-
@Override
@SuppressForbidden(
reason =
"Set the thread contextClassLoader for all 3rd party dependencies that we cannot control")
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
+ if (excludedPath(excludePatterns, request, response, chain)) {
+ return;
+ }
+
try (var mdcSnapshot = MDCSnapshot.create()) {
assert null != mdcSnapshot; // prevent compiler warning
MDCLoggingContext.reset();
MDCLoggingContext.setNode(getCores());
Thread.currentThread().setContextClassLoader(getCores().getResourceLoader().getClassLoader());
- doFilter(request, response, chain, false);
+ doFilterRetry(closeShield(request), closeShield(response), chain, false);
}
}
- public void doFilter(
- ServletRequest _request, ServletResponse _response, FilterChain chain, boolean retry)
+ protected void doFilterRetry(
+ HttpServletRequest request, HttpServletResponse response, FilterChain chain, boolean retry)
throws IOException, ServletException {
- if (!(_request instanceof HttpServletRequest)) return;
- HttpServletRequest request = closeShield((HttpServletRequest) _request, retry);
- HttpServletResponse response = closeShield((HttpServletResponse) _response, retry);
-
- if (excludedPath(excludePatterns, request, response, chain)) {
- return;
- }
Tracer t = getCores() == null ? GlobalTracer.get() : getCores().getTracer();
request.setAttribute(ATTR_TRACING_TRACER, t);
RateLimitManager rateLimitManager = containerProvider.getRateLimitManager();
@@ -256,7 +246,7 @@ public class SolrDispatchFilter extends BaseSolrFilter implements PathExcluder {
break;
case RETRY:
getSpan(request).log("SolrDispatchFilter RETRY");
- doFilter(request, response, chain, true); // RECURSION
+ doFilterRetry(request, response, chain, true); // RECURSION
break;
case FORWARD:
getSpan(request).log("SolrDispatchFilter FORWARD");