Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into SOLR-17540
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Dec 9, 2024
2 parents bc20356 + 4510baf commit c25e78b
Show file tree
Hide file tree
Showing 48 changed files with 227 additions and 679 deletions.
17 changes: 16 additions & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Improvements

Optimizations
---------------------
(No changes)
* SOLR-17568: The CLI bin/solr export tool now contacts the appropriate nodes directly for data instead of proxying through one.
(David Smiley)

Bug Fixes
---------------------
Expand Down Expand Up @@ -93,6 +94,12 @@ Deprecation Removals

* SOLR-17564: Remove code in Assign used for backwards compatibility with Collections created prior to 7.0 (Paul McArthur)

* SOLR-17576: Remove deprecated master/slave option language from ReplicationHandler. (Eric Pugh)

* SOLR-16781: Support for `<lib/>` directives (used in solrconfig.xml to add JARs on a core-by-core basis) has been removed. Users
looking for similar functionality can use Solr's package manager. Users that don't need to vary JAR access on a per-core basis
have many options, including the `<sharedLib/>` tag and directly modifying Solr's classpath prior to JVM startup. (Jason Gerlowski)

* SOLR-17540: Removed the Hadoop Auth module, and thus Kerberos authentication and other exotic options. (Eric Pugh)

Dependency Upgrades
Expand Down Expand Up @@ -132,6 +139,8 @@ Other Changes

* SOLR-16903: Update CLI tools to use java.nio.file.Path instead of java.io.File (Andrey Bozhko)

* SOLR-17568: SolrCloud no longer reroutes/proxies a core request to another node if not found locally. (David Smiley)

================== 9.8.0 ==================
New Features
---------------------
Expand Down Expand Up @@ -229,6 +238,10 @@ Bug Fixes
* 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)

* SOLR-17575: Fixed broken backwards compatibility with the legacy "langid.whitelist" config in Solr Langid. (Jan Høydahl, Alexander Zagniotov)

* SOLR-17574: Fix AllowListUrlChecker when liveNodes changes. Remove ClusterState.getHostAllowList (Bruno Roustant, David Smiley)

Dependency Upgrades
---------------------
(No changes)
Expand Down Expand Up @@ -258,6 +271,8 @@ led to the suppression of exceptions. (Andrey Bozhko)

* SOLR-17556: "home" and "data" directories used by Solr examples have been updated to align with documented best practices. (Eric Pugh, Houston Putman)

* SOLR-17577: Remove "solr.indexfetcher.sotimeout" system property that was for optimizing replication tests. It was disabled, but not removed. (Eric Pugh)

================== 9.7.1 ==================
Bug Fixes
---------------------
Expand Down
6 changes: 2 additions & 4 deletions solr/bin/solr.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -1170,11 +1170,9 @@ for %%a in (%*) do (
if "!arg:~0,1!" equ "-" set "option=!arg!"
) else (
set "option!option!=%%a"
if "!option!" equ "-s" set "SOLR_HOME=%%a"
if "!option!" equ "--solr-home" set "SOLR_HOME=%%a"
if "!option!" equ "-d" set "SOLR_SERVER_DIR=%%a"
if "!option!" equ "--server-dir" set "SOLR_SERVER_DIR=%%a"
if not "!option!" equ "-s" if not "!option!" equ "--solr-home" if not "!option!" equ "-d" if not "!option!" equ "--server-dir" (
if "!option!" equ "--server-dir" set "SOLR_SERVER_DIR=%%a"
if not "!option!" equ "--solr-home" if not "!option!" equ "--server-dir" (
set "AUTH_PARAMS=!AUTH_PARAMS! !option! %%a"
)
set "option="
Expand Down
2 changes: 1 addition & 1 deletion solr/core/src/java/org/apache/solr/api/V2HttpCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void call(SolrQueryRequest req, SolrQueryResponse rsp) {
core = getCoreByCollection(collectionName, isPreferLeader);
if (core == null) {
// this collection exists , but this node does not have a replica for that collection
extractRemotePath(collectionName, collectionName);
extractRemotePath(collectionName);
if (action == REMOTEQUERY) {
action = ADMIN_OR_REMOTEQUERY;
coreUrl = coreUrl.replace("/solr/", "/solr/____v2/c/");
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/java/org/apache/solr/cli/ExportTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,8 @@ class CoreHandler {
}

boolean exportDocsFromCore() throws IOException, SolrServerException {

try (SolrClient client = CLIUtils.getSolrClient(baseurl, credentials)) {
// reference the replica's node URL, not the baseUrl in scope, which could be anywhere
try (SolrClient client = CLIUtils.getSolrClient(replica.getBaseUrl(), credentials)) {
expectedDocs = getDocCount(replica.getCoreName(), client, query);
QueryRequest request;
ModifiableSolrParams params = new ModifiableSolrParams();
Expand Down
8 changes: 7 additions & 1 deletion solr/core/src/java/org/apache/solr/cli/RunExampleTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,11 @@ protected Map<String, Object> startSolr(
if (!isWindows && cwdPath.length() > 1 && solrHome.startsWith(cwdPath))
solrHome = solrHome.substring(cwdPath.length() + 1);

final var syspropArg =
("techproducts".equals(cli.getOptionValue(EXAMPLE_OPTION)))
? "-Dsolr.modules=clustering,extraction,langid,ltr,scripting -Dsolr.ltr.enabled=true -Dsolr.clustering.enabled=true"
: "";

String startCmd =
String.format(
Locale.ROOT,
Expand All @@ -661,7 +666,8 @@ protected Map<String, Object> startSolr(
forceArg,
verboseArg,
extraArgs,
jvmOptsArg);
jvmOptsArg,
syspropArg);
startCmd = startCmd.replaceAll("\\s+", " ").trim(); // for pretty printing

echo("\nStarting up Solr on port " + port + " using command:");
Expand Down
9 changes: 4 additions & 5 deletions solr/core/src/java/org/apache/solr/core/ConfigSetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public final ConfigSet loadConfigSet(CoreDescriptor dcore) {
NamedList<?> properties = loadConfigSetProperties(dcore, coreLoader);
boolean trusted = isConfigSetTrusted(coreLoader);

SolrConfig solrConfig = createSolrConfig(dcore, coreLoader, trusted);
SolrConfig solrConfig = createSolrConfig(dcore, coreLoader);
return new ConfigSet(
configSetName(dcore),
solrConfig,
Expand Down Expand Up @@ -314,13 +314,12 @@ public ConfigSetService(SolrResourceLoader loader, boolean shareSchema) {
*
* @param cd the core's CoreDescriptor
* @param loader the core's resource loader
* @param isTrusted is the configset trusted?
* @return a SolrConfig object
*/
protected SolrConfig createSolrConfig(
CoreDescriptor cd, SolrResourceLoader loader, boolean isTrusted) throws IOException {
protected SolrConfig createSolrConfig(CoreDescriptor cd, SolrResourceLoader loader)
throws IOException {
return SolrConfig.readFromResourceLoader(
loader, cd.getConfigName(), isTrusted, cd.getSubstitutableProperties());
loader, cd.getConfigName(), cd.getSubstitutableProperties());
}

/**
Expand Down
71 changes: 13 additions & 58 deletions solr/core/src/java/org/apache/solr/core/SolrConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.apache.solr.core;

import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.CommonParams.PATH;
import static org.apache.solr.core.ConfigOverlay.ZNODEVER;
import static org.apache.solr.core.SolrConfig.PluginOpts.LAZY;
import static org.apache.solr.core.SolrConfig.PluginOpts.MULTI_OK;
Expand All @@ -31,7 +30,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.invoke.MethodHandles;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -96,7 +94,7 @@

/**
* Provides a static reference to a Config object modeling the main configuration data for a Solr
* instance -- typically found in "solrconfig.xml".
* core -- typically found in "solrconfig.xml".
*/
public class SolrConfig implements MapSerializable {

Expand Down Expand Up @@ -143,16 +141,13 @@ public enum PluginOpts {
* @param name the configuration name used by the loader if the stream is null
*/
public SolrConfig(Path instanceDir, String name) throws IOException {
this(new SolrResourceLoader(instanceDir), name, true, null);
this(new SolrResourceLoader(instanceDir), name, null);
}

public static SolrConfig readFromResourceLoader(
SolrResourceLoader loader,
String name,
boolean isConfigsetTrusted,
Properties substitutableProperties) {
SolrResourceLoader loader, String name, Properties substitutableProperties) {
try {
return new SolrConfig(loader, name, isConfigsetTrusted, substitutableProperties);
return new SolrConfig(loader, name, substitutableProperties);
} catch (Exception e) {
String resource;
if (loader instanceof ZkSolrResourceLoader) {
Expand Down Expand Up @@ -196,15 +191,9 @@ public InputStream apply(String s) {
*
* @param loader the resource loader
* @param name the configuration name
* @param isConfigsetTrusted false if configset was uploaded using unsecured configset upload API,
* true otherwise
* @param substitutableProperties optional properties to substitute into the XML
*/
private SolrConfig(
SolrResourceLoader loader,
String name,
boolean isConfigsetTrusted,
Properties substitutableProperties) {
private SolrConfig(SolrResourceLoader loader, String name, Properties substitutableProperties) {
this.resourceLoader = loader;
this.resourceName = name;
this.substituteProperties = substitutableProperties;
Expand Down Expand Up @@ -237,7 +226,7 @@ private SolrConfig(
rootDataHashCode = this.root.txt().hashCode();

getRequestParams();
initLibs(loader, isConfigsetTrusted);
initLibs(loader);
String val =
root.child(
IndexSchema.LUCENE_MATCH_VERSION_PARAM,
Expand Down Expand Up @@ -934,11 +923,10 @@ public PluginInfo getPluginInfo(String type) {
SolrException.ErrorCode.SERVER_ERROR, "Multiple plugins configured for type: " + type);
}

private void initLibs(SolrResourceLoader loader, boolean isConfigsetTrusted) {
private void initLibs(SolrResourceLoader loader) {
// TODO Want to remove SolrResourceLoader.getInstancePath; it can be on a Standalone subclass.
// For Zk subclass, it's needed for the time being as well. We could remove that one if we
// remove two things in SolrCloud: (1) instancePath/lib and (2) solrconfig lib directives with
// relative paths. Can wait till 9.0.
// remove "instancePath/lib" in SolrCloud. Can wait till 9.0.
Path instancePath = loader.getInstancePath();
List<URL> urls = new ArrayList<>();

Expand All @@ -950,48 +938,15 @@ private void initLibs(SolrResourceLoader loader, boolean isConfigsetTrusted) {
log.warn("Couldn't add files from {} to classpath: {}", libPath, e);
}
}

List<ConfigNode> nodes = root.getAll("lib");
if (nodes != null && nodes.size() > 0) {
if (!isConfigsetTrusted) {
throw new SolrException(
ErrorCode.UNAUTHORIZED,
"The configset for this collection was uploaded without any authentication in place,"
+ " and use of <lib> is not available for collections with untrusted configsets. To use this component, re-upload the configset"
+ " after enabling authentication and authorization.");
}

for (int i = 0; i < nodes.size(); i++) {
ConfigNode node = nodes.get(i);
String baseDir = node.attr("dir");
String path = node.attr(PATH);
if (null != baseDir) {
// :TODO: add support for a simpler 'glob' mutually exclusive of regex
Path dir = instancePath.resolve(baseDir);
String regex = node.attr("regex");
try {
if (regex == null) urls.addAll(SolrResourceLoader.getURLs(dir));
else urls.addAll(SolrResourceLoader.getFilteredURLs(dir, regex));
} catch (IOException e) {
log.warn("Couldn't add files from {} filtered by {} to classpath: {}", dir, regex, e);
}
} else if (null != path) {
final Path dir = instancePath.resolve(path);
try {
urls.add(dir.toUri().toURL());
} catch (MalformedURLException e) {
log.warn("Couldn't add file {} to classpath: {}", dir, e);
}
} else {
throw new RuntimeException("lib: missing mandatory attributes: 'dir' or 'path'");
}
}
}

if (!urls.isEmpty()) {
loader.addToClassLoader(urls);
loader.reloadLuceneSPI();
}

List<ConfigNode> nodes = root.getAll("lib");
if (nodes != null && nodes.size() > 0) {
log.warn("<lib/> entries no longer supported in solrconfig.xml; ignoring...");
}
}

public int getMultipartUploadLimitKB() {
Expand Down
19 changes: 3 additions & 16 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import static org.apache.solr.handler.ReplicationHandler.CONF_FILES;
import static org.apache.solr.handler.ReplicationHandler.FETCH_FROM_LEADER;
import static org.apache.solr.handler.ReplicationHandler.LEADER_URL;
import static org.apache.solr.handler.ReplicationHandler.LEGACY_LEADER_URL;
import static org.apache.solr.handler.ReplicationHandler.LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO;
import static org.apache.solr.handler.ReplicationHandler.SIZE;
import static org.apache.solr.handler.ReplicationHandler.SKIP_COMMIT_ON_LEADER_VERSION_ZERO;
import static org.apache.solr.handler.admin.api.ReplicationAPIBase.CHECKSUM;
Expand Down Expand Up @@ -279,17 +277,11 @@ public IndexFetcher(
if (fetchFromLeader != null && fetchFromLeader instanceof Boolean) {
this.fetchFromLeader = (boolean) fetchFromLeader;
}
Object skipCommitOnLeaderVersionZero =
ReplicationHandler.getObjectWithBackwardCompatibility(
initArgs,
SKIP_COMMIT_ON_LEADER_VERSION_ZERO,
LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO);
Object skipCommitOnLeaderVersionZero = initArgs.get(SKIP_COMMIT_ON_LEADER_VERSION_ZERO);
if (skipCommitOnLeaderVersionZero != null && skipCommitOnLeaderVersionZero instanceof Boolean) {
this.skipCommitOnLeaderVersionZero = (boolean) skipCommitOnLeaderVersionZero;
}
String leaderUrl =
ReplicationHandler.getObjectWithBackwardCompatibility(
initArgs, LEADER_URL, LEGACY_LEADER_URL);
String leaderUrl = (String) initArgs.get(LEADER_URL);
if (leaderUrl == null && !this.fetchFromLeader)
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR, "'leaderUrl' is required for a follower");
Expand All @@ -304,13 +296,8 @@ public IndexFetcher(
useInternalCompression = ReplicationHandler.INTERNAL.equals(compress);
useExternalCompression = ReplicationHandler.EXTERNAL.equals(compress);
connTimeout = getParameter(initArgs, HttpClientUtil.PROP_CONNECTION_TIMEOUT, 30000, null);
soTimeout = getParameter(initArgs, HttpClientUtil.PROP_SO_TIMEOUT, 120000, null);

// allow a leader override for tests - you specify this in /replication follower section of
// solrconfig and some test don't want to define this
soTimeout = Integer.getInteger("solr.indexfetcher.sotimeout", -1);
if (soTimeout == -1) {
soTimeout = getParameter(initArgs, HttpClientUtil.PROP_SO_TIMEOUT, 120000, null);
}
String httpBasicAuthUser = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_USER);
String httpBasicAuthPassword = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_PASS);
solrClient =
Expand Down
Loading

0 comments on commit c25e78b

Please sign in to comment.