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/10/01 23:47:06 UTC
[lucene-solr] 25/26: @907 Tweaks.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 27fd7cb06f31ff38b67318f561a4be3bee03a7a8
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Oct 1 18:16:39 2020 -0500
@907 Tweaks.
---
.../org/apache/solr/update/SolrCmdDistributor.java | 3 +-
.../src/java/org/apache/solr/update/UpdateLog.java | 44 +++++++++++-----------
.../solr/client/solrj/impl/Http2SolrClient.java | 8 +++-
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index 1a9d08e..f2778d8 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -67,7 +67,7 @@ public class SolrCmdDistributor implements Closeable {
public SolrCmdDistributor(UpdateShardHandler updateShardHandler) {
assert ObjectReleaseTracker.track(this);
- this.solrClient = new Http2SolrClient.Builder().withHttpClient(updateShardHandler.getTheSharedHttpClient()).build();
+ this.solrClient = new Http2SolrClient.Builder().withHttpClient(updateShardHandler.getTheSharedHttpClient()).maxRequestsQueuedPerDestination(8192).build();
}
public void finish() {
@@ -286,6 +286,7 @@ public class SolrCmdDistributor implements Closeable {
ParWork.propagateInterrupt(e1);
}
}
+ log.info("Retrying distrib update on error: {}", e.getMessage());
submit(req);
} else {
allErrors.add(error);
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 6e98fec..eed84fa 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -234,7 +234,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
protected volatile String[] tlogFiles;
protected volatile File tlogDir;
protected volatile Collection<String> globalStrings;
- private final Object gsLock = new Object();
+ private final ReentrantLock gsLock = new ReentrantLock(true);
protected volatile String dataDir;
protected volatile String lastDataDir;
@@ -592,13 +592,8 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
bufferTlog.write(cmd);
return;
}
- } finally {
- tlogLock.unlock();
- }
- long pos = -1;
- long prevPointer;
- tlogLock.lock();
- try {
+ long pos = -1;
+ long prevPointer;
prevPointer = getPrevPointerForUpdate(cmd);
@@ -662,19 +657,13 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
public void delete(DeleteUpdateCommand cmd) {
BytesRef br = cmd.getIndexedId();
-
- if ((cmd.getFlags() & UpdateCommand.BUFFERING) != 0) {
+ try {
tlogLock.lock();
- try {
+ if ((cmd.getFlags() & UpdateCommand.BUFFERING) != 0) {
ensureBufferTlog();
bufferTlog.writeDelete(cmd);
return;
- } finally {
- tlogLock.unlock();
}
- }
- tlogLock.lock();
- try {
long pos = -1;
if (!updateFromOldTlogs(cmd)) {
ensureLog();
@@ -891,8 +880,11 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
tlogLock.lock();
try {
if (prevTlog != null) {
- synchronized (gsLock) {
+ gsLock.lock();
+ try {
globalStrings = prevTlog.getGlobalStrings();
+ } finally {
+ gsLock.unlock();
}
// since document additions can happen concurrently with commit, create
@@ -1167,14 +1159,14 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
entry = oldDeletes.get(indexedId);
+ if (entry != null) {
+ return entry.version;
+ }
+
} finally {
tlogLock.unlock();
}
- if (entry != null) {
- return entry.version;
- }
-
return null;
}
@@ -1423,8 +1415,11 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
protected void ensureBufferTlog() {
if (bufferTlog != null) return;
String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, BUFFER_TLOG_NAME, System.nanoTime());
- synchronized (gsLock) {
+ gsLock.lock();
+ try {
bufferTlog = newTransactionLog(new File(tlogDir, newLogName), globalStrings, false, new byte[4096]);
+ } finally {
+ gsLock.unlock();
}
bufferTlog.isBuffer = true;
}
@@ -1444,11 +1439,14 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
if (tlog == null) {
tlogLock.lock();
try {
- synchronized (gsLock) {
+ gsLock.lock();
+ try {
if (tlog == null) {
String newLogName = String.format(Locale.ROOT, LOG_FILENAME_PATTERN, TLOG_NAME, id);
tlog = newTransactionLog(new File(tlogDir, newLogName), globalStrings, false, new byte[4096]);
}
+ } finally {
+ gsLock.unlock();
}
} finally {
tlogLock.unlock();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 136f446..f15ccf1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -252,7 +252,7 @@ public class Http2SolrClient extends SolrClient {
httpClient.setConnectBlocking(false);
httpClient.setFollowRedirects(false);
if (builder.maxConnectionsPerHost != null) httpClient.setMaxConnectionsPerDestination(builder.maxConnectionsPerHost);
- httpClient.setMaxRequestsQueuedPerDestination(4096);
+ httpClient.setMaxRequestsQueuedPerDestination(builder.maxRequestsQueuedPerDestination);
httpClient.setRequestBufferSize(8192);
httpClient.setUserAgentField(new HttpField(HttpHeader.USER_AGENT, AGENT));
httpClient.setIdleTimeout(idleTimeout);
@@ -963,6 +963,7 @@ public class Http2SolrClient extends SolrClient {
public static class Builder {
public int maxThreadPoolSize = Integer.getInteger("solr.maxHttp2ClientThreads", Math.max(256, ParWork.PROC_COUNT));
+ public int maxRequestsQueuedPerDestination = 2048;
private Http2SolrClient http2SolrClient;
private SSLConfig sslConfig = defaultSSLConfig;
private Integer idleTimeout = Integer.getInteger("solr.http2solrclient.default.idletimeout", 120000);
@@ -1007,6 +1008,11 @@ public class Http2SolrClient extends SolrClient {
return this;
}
+ public Builder maxRequestsQueuedPerDestination(int max) {
+ this.maxRequestsQueuedPerDestination = max;
+ return this;
+ }
+
public Builder maxThreadPoolSize(int max) {
this.maxThreadPoolSize = max;
return this;