Skip to content

Commit cb6dd31

Browse files
epughdsmiley
andauthored
SOLR-17932: Remove deprecated Solr Transient Cores (#3699)
* Remove transient cores * .lazy is no longer a metric, removed from various tests related to metrics * Remove (Core) CloserThread and remove SolrCores.pendingCloses --------- Co-authored-by: David Smiley <[email protected]>
1 parent 1121d24 commit cb6dd31

File tree

30 files changed

+87
-1371
lines changed

30 files changed

+87
-1371
lines changed

solr/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Deprecation Removals
165165
for that (which will be removed eventually), and many tests still use it. Also, there were server metrics
166166
relating to HTTP client connection pools that no longer exist. (David Smiley)
167167

168+
* SOLR-17932: Remove transient Solr cores capability. (Eric Pugh, David Smiley)
169+
168170
Dependency Upgrades
169171
---------------------
170172

solr/api/src/java/org/apache/solr/client/api/model/CreateCoreParams.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.apache.solr.client.api.model;
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
20-
import io.swagger.v3.oas.annotations.media.Schema;
2120
import java.util.Map;
2221

2322
public class CreateCoreParams {
@@ -38,10 +37,6 @@ public class CreateCoreParams {
3837

3938
@JsonProperty public Boolean loadOnStartup;
4039

41-
@Schema(name = "isTransient")
42-
@JsonProperty("transient")
43-
public Boolean isTransient;
44-
4540
@JsonProperty public String shard;
4641

4742
@JsonProperty public String collection;

solr/core/src/java/org/apache/solr/core/CoreContainer.java

Lines changed: 12 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ public JerseyAppHandlerCache getJerseyAppHandlerCache() {
239239

240240
protected volatile LogWatcher<?> logging = null;
241241

242-
private volatile CloserThread backgroundCloser = null;
243242
protected final NodeConfig cfg;
244243
protected final SolrResourceLoader loader;
245244

@@ -894,12 +893,6 @@ private void loadInternal() {
894893
"loaded",
895894
SolrInfoBean.Category.CONTAINER.toString(),
896895
"cores");
897-
solrMetricsContext.gauge(
898-
solrCores::getNumLoadedTransientCores,
899-
true,
900-
"lazy",
901-
SolrInfoBean.Category.CONTAINER.toString(),
902-
"cores");
903896
solrMetricsContext.gauge(
904897
solrCores::getNumUnloadedCores,
905898
true,
@@ -1028,7 +1021,7 @@ private void loadInternal() {
10281021
status |= CORE_DISCOVERY_COMPLETE;
10291022

10301023
for (final CoreDescriptor cd : cds) {
1031-
if (cd.isTransient() || !cd.isLoadOnStartup()) {
1024+
if (!cd.isLoadOnStartup()) {
10321025
solrCores.addCoreDescriptor(cd);
10331026
} else if (asyncSolrCoreLoad) {
10341027
solrCores.markCoreAsLoading(cd);
@@ -1069,10 +1062,6 @@ private void loadInternal() {
10691062
}
10701063
}
10711064

1072-
// Start the background thread
1073-
backgroundCloser = new CloserThread(this, solrCores, cfg);
1074-
backgroundCloser.start();
1075-
10761065
} finally {
10771066
coreLoadExecutor.shutdown(); // doesn't block
10781067
if (!asyncSolrCoreLoad) {
@@ -1259,31 +1248,6 @@ public void shutdown() {
12591248

12601249
ExecutorUtil.shutdownAndAwaitTermination(coreLoadExecutor); // actually already shutdown
12611250

1262-
// First wake up the closer thread, it'll terminate almost immediately since it checks
1263-
// isShutDown.
1264-
synchronized (solrCores.getModifyLock()) {
1265-
solrCores.getModifyLock().notifyAll(); // wake up anyone waiting
1266-
}
1267-
if (backgroundCloser
1268-
!= null) { // Doesn't seem right, but tests get in here without initializing the core.
1269-
try {
1270-
while (true) {
1271-
backgroundCloser.join(15000);
1272-
if (backgroundCloser.isAlive()) {
1273-
synchronized (solrCores.getModifyLock()) {
1274-
solrCores.getModifyLock().notifyAll(); // there is a race we have to protect against
1275-
}
1276-
} else {
1277-
break;
1278-
}
1279-
}
1280-
} catch (InterruptedException e) {
1281-
Thread.currentThread().interrupt();
1282-
if (log.isDebugEnabled()) {
1283-
log.debug("backgroundCloser thread was interrupted before finishing");
1284-
}
1285-
}
1286-
}
12871251
// Now clear all the cores that are being operated upon.
12881252
solrCores.close();
12891253

@@ -1877,13 +1841,8 @@ public List<SolrCore> getCores() {
18771841
}
18781842

18791843
/**
1880-
* Gets the permanent and transient cores that are currently loaded, i.e. cores that have 1:
1881-
* loadOnStartup=true and are either not-transient or, if transient, have been loaded and have not
1882-
* been aged out 2: loadOnStartup=false and have been loaded but are either non-transient or have
1883-
* not been aged out.
1884-
*
1885-
* <p>Put another way, this will not return any names of cores that are lazily loaded but have not
1886-
* been called for yet or are transient and either not loaded or have been swapped out.
1844+
* Gets the cores that are currently loaded, i.e. cores that have 1: loadOnStartup=true and have
1845+
* been loaded and 2: loadOnStartup=false and have been subsequently loaded.
18871846
*
18881847
* <p>For efficiency, prefer to check {@link #isLoaded(String)} instead of {@link
18891848
* #getLoadedCoreNames()}.contains(coreName).
@@ -1896,8 +1855,7 @@ public List<String> getLoadedCoreNames() {
18961855
}
18971856

18981857
/**
1899-
* Gets a collection of all the cores, permanent and transient, that are currently known, whether
1900-
* they are loaded or not.
1858+
* Gets a collection of all the cores that are currently known, whether they are loaded or not.
19011859
*
19021860
* <p>For efficiency, prefer to check {@link #getCoreDescriptor(String)} != null instead of {@link
19031861
* #getAllCoreNames()}.contains(coreName).
@@ -1910,8 +1868,8 @@ public List<String> getAllCoreNames() {
19101868
}
19111869

19121870
/**
1913-
* Gets the total number of cores, including permanent and transient cores, loaded and unloaded
1914-
* cores. Faster equivalent for {@link #getAllCoreNames()}.size().
1871+
* Gets the total number of cores, including both loaded and unloaded cores. Faster equivalent to
1872+
* {@link #getAllCoreNames()}.size().
19151873
*/
19161874
public int getNumAllCores() {
19171875
return solrCores.getNumAllCores();
@@ -2143,16 +2101,11 @@ private void unloadWithoutCoreOp(
21432101
ErrorCode.BAD_REQUEST, "Cannot unload non-existent core [" + name + "]");
21442102
}
21452103

2146-
boolean close = solrCores.isLoadedNotPendingClose(name);
2104+
boolean close = solrCores.isLoaded(name);
21472105
SolrCore core = solrCores.remove(name);
21482106

21492107
solrCores.removeCoreDescriptor(cd);
21502108
coresLocator.delete(this, cd);
2151-
if (core == null) {
2152-
// transient core
2153-
SolrCore.deleteUnloadedCore(cd, deleteDataDir, deleteInstanceDir);
2154-
return;
2155-
}
21562109

21572110
// delete metrics specific to this core
21582111
metricManager.removeRegistry(core.getCoreMetricManager().getRegistryName());
@@ -2264,16 +2217,13 @@ public SolrCore getCore(String name, UUID id) {
22642217
// if there was an error initializing this core, throw a 500
22652218
// error with the details for clients attempting to access it.
22662219
CoreLoadFailure loadFailure = getCoreInitFailures().get(name);
2267-
if (null != loadFailure) {
2220+
if (loadFailure != null) {
22682221
throw new SolrCoreInitializationException(name, loadFailure.exception);
22692222
}
2270-
// This is a bit of awkwardness where SolrCloud and transient cores don't play nice together.
2271-
// For transient cores, we have to allow them to be created at any time there hasn't been a core
2272-
// load failure (use reload to cure that). But for
2273-
// TestConfigSetsAPI.testUploadWithScriptUpdateProcessor, this needs to _not_ try to load the
2274-
// core if the core is null and there was an error. If you change this, be sure to run both
2275-
// TestConfigSetsAPI and TestLazyCores
2276-
if (desc == null || zkSys.getZkController() != null) return null;
2223+
2224+
if (desc == null || zkSys.getZkController() != null) {
2225+
return null;
2226+
}
22772227

22782228
// This will put an entry in pending core ops if the core isn't loaded. Here's where moving the
22792229
// waitAddPendingCoreOps to createFromDescriptor would introduce a race condition.
@@ -2574,45 +2524,3 @@ public void addKeyVal(Object map, Object key, Object val) throws IOException {
25742524
});
25752525
}
25762526
}
2577-
2578-
class CloserThread extends Thread {
2579-
CoreContainer container;
2580-
SolrCores solrCores;
2581-
NodeConfig cfg;
2582-
2583-
CloserThread(CoreContainer container, SolrCores solrCores, NodeConfig cfg) {
2584-
super("CloserThread");
2585-
this.container = container;
2586-
this.solrCores = solrCores;
2587-
this.cfg = cfg;
2588-
}
2589-
2590-
// It's important that this be the _only_ thread removing things from pendingDynamicCloses!
2591-
// This is single-threaded, but I tried a multithreaded approach and didn't see any performance
2592-
// gains, so there's no good justification for the complexity. I suspect that the locking on
2593-
// things like DefaultSolrCoreState essentially create a single-threaded process anyway.
2594-
@Override
2595-
public void run() {
2596-
while (!container.isShutDown()) {
2597-
synchronized (solrCores.getModifyLock()) { // need this so we can wait and be awoken.
2598-
try {
2599-
solrCores.getModifyLock().wait();
2600-
} catch (InterruptedException e) {
2601-
// Well, if we've been told to stop, we will. Otherwise, continue on and check to see if
2602-
// there are any cores to close.
2603-
}
2604-
}
2605-
2606-
SolrCore core;
2607-
while (!container.isShutDown() && (core = solrCores.getCoreToClose()) != null) {
2608-
assert core.getOpenCount() == 1;
2609-
try {
2610-
MDCLoggingContext.setCore(core);
2611-
core.close(); // will clear MDC
2612-
} finally {
2613-
solrCores.removeFromPendingOps(core.getName());
2614-
}
2615-
}
2616-
}
2617-
}
2618-
}

solr/core/src/java/org/apache/solr/core/CoreDescriptor.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class CoreDescriptor {
5656
public static final String CORE_COLLECTION = "collection";
5757
public static final String CORE_PROPERTIES = "properties";
5858
public static final String CORE_LOADONSTARTUP = "loadOnStartup";
59-
public static final String CORE_TRANSIENT = "transient";
6059
public static final String CORE_NODE_NAME = "coreNodeName";
6160
public static final String CORE_CONFIGSET = "configSet";
6261
public static final String CORE_CONFIGSET_PROPERTIES = "configSetProperties";
@@ -89,7 +88,6 @@ public Properties getPersistableUserProperties() {
8988
CORE_SCHEMA, "schema.xml",
9089
CORE_CONFIGSET_PROPERTIES, ConfigSetProperties.DEFAULT_FILENAME,
9190
CORE_DATADIR, "data" + FileSystems.getDefault().getSeparator(),
92-
CORE_TRANSIENT, "false",
9391
CORE_LOADONSTARTUP, "true");
9492

9593
private static final List<String> requiredProperties = List.of(CORE_NAME);
@@ -104,7 +102,6 @@ public Properties getPersistableUserProperties() {
104102
CORE_PROPERTIES,
105103
CORE_CONFIGSET_PROPERTIES,
106104
CORE_LOADONSTARTUP,
107-
CORE_TRANSIENT,
108105
CORE_CONFIGSET,
109106
// cloud props
110107
CORE_SHARD,
@@ -338,11 +335,6 @@ public boolean isLoadOnStartup() {
338335
return Boolean.parseBoolean(stringValue);
339336
}
340337

341-
public boolean isTransient() {
342-
String stringValue = coreProperties.getProperty(CORE_TRANSIENT, "false");
343-
return PropertiesUtil.toBoolean(stringValue);
344-
}
345-
346338
public String getUlogDir() {
347339
return coreProperties.getProperty(CORE_ULOGDIR);
348340
}

solr/core/src/java/org/apache/solr/core/NodeConfig.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ public class NodeConfig {
107107

108108
private final int indexSearcherExecutorThreads;
109109

110-
@Deprecated private final int transientCacheSize;
111-
112110
private final boolean useSchemaCache;
113111

114112
private final String managementPath;
@@ -147,7 +145,6 @@ private NodeConfig(
147145
Integer coreLoadThreads,
148146
int replayUpdatesThreads,
149147
int indexSearcherExecutorThreads,
150-
int transientCacheSize,
151148
boolean useSchemaCache,
152149
String managementPath,
153150
Path solrHome,
@@ -187,7 +184,6 @@ private NodeConfig(
187184
this.coreLoadThreads = coreLoadThreads;
188185
this.replayUpdatesThreads = replayUpdatesThreads;
189186
this.indexSearcherExecutorThreads = indexSearcherExecutorThreads;
190-
this.transientCacheSize = transientCacheSize;
191187
this.useSchemaCache = useSchemaCache;
192188
this.managementPath = managementPath;
193189
this.solrHome = solrHome;
@@ -401,10 +397,6 @@ public CloudConfig getCloudConfig() {
401397
return cloudConfig;
402398
}
403399

404-
public int getTransientCacheSize() {
405-
return transientCacheSize;
406-
}
407-
408400
protected final Path solrHome;
409401
protected final SolrResourceLoader loader;
410402
protected final Properties solrProperties;
@@ -607,7 +599,6 @@ public static class NodeConfigBuilder {
607599
private int coreLoadThreads = DEFAULT_CORE_LOAD_THREADS;
608600
private int replayUpdatesThreads = Runtime.getRuntime().availableProcessors();
609601
private int indexSearcherExecutorThreads = DEFAULT_INDEX_SEARCHER_EXECUTOR_THREADS;
610-
@Deprecated private int transientCacheSize = -1;
611602
private boolean useSchemaCache = false;
612603
private String managementPath;
613604
private Properties solrProperties = new Properties();
@@ -773,14 +764,6 @@ public NodeConfigBuilder setIndexSearcherExecutorThreads(int indexSearcherExecut
773764
return this;
774765
}
775766

776-
// Remove in Solr 10.0
777-
778-
@Deprecated
779-
public NodeConfigBuilder setTransientCacheSize(int transientCacheSize) {
780-
this.transientCacheSize = transientCacheSize;
781-
return this;
782-
}
783-
784767
public NodeConfigBuilder setUseSchemaCache(boolean useSchemaCache) {
785768
this.useSchemaCache = useSchemaCache;
786769
return this;
@@ -915,7 +898,6 @@ public NodeConfig build() {
915898
coreLoadThreads,
916899
replayUpdatesThreads,
917900
indexSearcherExecutorThreads,
918-
transientCacheSize,
919901
useSchemaCache,
920902
managementPath,
921903
solrHome,

0 commit comments

Comments
 (0)