You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/09/01 18:54:15 UTC
[lucene-solr] 01/11: @667 Trying to work out an exec leak in
CloudSolrClientCacheTest.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit cac2ca2cd715ffee4b7c3557d88bc70c7d8e1679
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Sep 1 09:56:22 2020 -0500
@667 Trying to work out an exec leak in CloudSolrClientCacheTest.
---
.../solr/client/solrj/impl/BaseCloudSolrClient.java | 16 ++++++++++------
.../java/org/apache/solr/common/util/ExecutorUtil.java | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index c1673c8..7a9f7b5 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -112,7 +112,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
private final boolean directUpdatesToLeadersOnly;
private final RequestReplicaListTransformerGenerator requestRLTGenerator;
boolean parallelUpdates; //TODO final
- private ExecutorService threadPool;
+ private final ExecutorService threadPool;
private String idField = ID;
public static final String STATE_VERSION = "_stateVer_";
private long retryExpiryTime = TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);//3 seconds or 3 million nanos
@@ -145,7 +145,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
@Override
public ExpiringCachedDocCollection get(Object key) {
ExpiringCachedDocCollection val = super.get(key);
- if(val == null) {
+ if (val == null) {
// a new collection is likely to be added now.
//check if there are stale items and remove them
evictStale();
@@ -192,17 +192,19 @@ public abstract class BaseCloudSolrClient extends SolrClient {
protected final StateCache collectionStateCache = new StateCache();
- class ExpiringCachedDocCollection {
+ static class ExpiringCachedDocCollection {
final DocCollection cached;
final long cachedAt;
+ private final long retryExpiryTime;
//This is the time at which the collection is retried and got the same old version
volatile long retriedAt = -1;
//flag that suggests that this is potentially to be rechecked
volatile boolean maybeStale = false;
- ExpiringCachedDocCollection(DocCollection cached) {
+ ExpiringCachedDocCollection(DocCollection cached, long retryExpiryTime) {
this.cached = cached;
this.cachedAt = System.nanoTime();
+ this.retryExpiryTime = retryExpiryTime;
}
boolean isExpired(long timeToLiveMs) {
@@ -231,6 +233,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
threadPool = ExecutorUtil
.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory(
"CloudSolrClient ThreadPool"));
+ } else {
+ threadPool = null;
}
this.updatesToLeaders = updatesToLeaders;
this.parallelUpdates = parallelUpdates;
@@ -1029,7 +1033,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// looks like we couldn't reach the server because the state was stale == retry
stateWasStale = true;
// we just pulled state from ZK, so update the cache so that the retry uses it
- collectionStateCache.put(ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk));
+ collectionStateCache.put(ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk, retryExpiryTime));
}
}
}
@@ -1319,7 +1323,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
cacheEntry.maybeStale = false;
} else {
if (fetchedCol.getStateFormat() > 1)
- collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol));
+ collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol, retryExpiryTime));
}
return fetchedCol;
}
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
index 0eeb9e7..0af78c4 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
@@ -81,7 +81,7 @@ public class ExecutorUtil {
public static void awaitTermination(ExecutorService pool) {
boolean shutdown = false;
// if interrupted, we still wait a short time for thread stoppage, but then quickly bail
- TimeOut interruptTimeout = new TimeOut(3000, TimeUnit.MILLISECONDS, TimeSource.NANO_TIME);
+ TimeOut interruptTimeout = new TimeOut(10000, TimeUnit.MILLISECONDS, TimeSource.NANO_TIME);
TimeOut shutdownTimeout = new TimeOut(30000, TimeUnit.MILLISECONDS, TimeSource.NANO_TIME);
boolean interrupted = false;
do {