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 2021/02/11 05:21:46 UTC
[lucene-solr] branch reference_impl_dev updated: @1344 Remove locks,
use more efficient get leader for dist commit.
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
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new ea84f72 @1344 Remove locks, use more efficient get leader for dist commit.
ea84f72 is described below
commit ea84f72e2d9cde5c3af0c40be34ccd4d14316c4f
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Feb 10 23:21:10 2021 -0600
@1344 Remove locks, use more efficient get leader for dist commit.
---
.../processor/DistributedZkUpdateProcessor.java | 2 +-
.../client/solrj/impl/BaseCloudSolrClient.java | 49 ++++++++--------------
2 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
index fab2429..84a7c71 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
@@ -191,7 +191,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
EnumSet.of(Replica.Type.TLOG, Replica.Type.NRT), true);
try {
- leaderReplica = zkController.getZkStateReader().getLeaderRetry(collection, cloudDesc.getShardId(), 3000, true);
+ leaderReplica = clusterState.getCollection(collection).getSlice(cloudDesc.getShardId()).getLeader();
} catch (Exception e) {
ParWork.propagateInterrupt(e);
throw new SolrException(ErrorCode.SERVER_ERROR,
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 59f6c80..6674ac5 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
@@ -82,7 +82,6 @@ import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
import org.apache.solr.common.util.ExecutorUtil;
-import org.apache.solr.common.util.Hash;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.util.StrUtils;
@@ -131,8 +130,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// NON_ROUTABLE_PARAMS.add(UpdateParams.ROLLBACK);
}
- private volatile List<Object> locks = objectList(3);
-
static class StateCache extends ConcurrentHashMap<String, ExpiringCachedDocCollection> {
final AtomicLong puts = new AtomicLong();
@@ -1249,11 +1246,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return directUpdatesToLeadersOnly;
}
- /**If caches are expired they are refreshed after acquiring a lock.
- * use this to set the number of locks
- */
- public void setParallelCacheRefreshes(int n){ locks = objectList(n); }
-
protected static ArrayList<Object> objectList(int n) {
ArrayList<Object> l = new ArrayList<>(n);
for(int i=0;i<n;i++) l.add(new Object());
@@ -1267,8 +1259,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
ExpiringCachedDocCollection cacheEntry = collectionStateCache.get(collection);
DocCollection col = cacheEntry == null ? null : cacheEntry.cached;
if (col != null) {
- if (expectedVersion <= col.getZNodeVersion()
- && !cacheEntry.shouldRetry()) return col;
+ if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col;
}
ClusterState.CollectionRef ref = getCollectionRef(collection);
@@ -1280,29 +1271,25 @@ public abstract class BaseCloudSolrClient extends SolrClient {
//it is readily available just return it
return ref.get();
}
- List locks = this.locks;
- final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size()));
+
DocCollection fetchedCol = null;
- synchronized (lock) {
- /*we have waited for sometime just check once again*/
- cacheEntry = collectionStateCache.get(collection);
- col = cacheEntry == null ? null : cacheEntry.cached;
- if (col != null) {
- if (expectedVersion <= col.getZNodeVersion()
- && !cacheEntry.shouldRetry()) return col;
- }
- // We are going to fetch a new version
- // we MUST try to get a new version
- fetchedCol = ref.get();//this is a call to ZK
- if (fetchedCol == null) return null;// this collection no more exists
- if (col != null && fetchedCol.getZNodeVersion() == col.getZNodeVersion()) {
- cacheEntry.setRetriedAt();//we retried and found that it is the same version
- cacheEntry.maybeStale = false;
- } else {
- collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol, retryExpiryTime));
- }
- return fetchedCol;
+ /*we have waited for sometime just check once again*/
+ cacheEntry = collectionStateCache.get(collection);
+ col = cacheEntry == null ? null : cacheEntry.cached;
+ if (col != null) {
+ if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col;
+ }
+ // We are going to fetch a new version
+ // we MUST try to get a new version
+ fetchedCol = ref.get();//this is a call to ZK
+ if (fetchedCol == null) return null;// this collection no more exists
+ if (col != null && fetchedCol.getZNodeVersion() == col.getZNodeVersion()) {
+ cacheEntry.setRetriedAt();//we retried and found that it is the same version
+ cacheEntry.maybeStale = false;
+ } else {
+ collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol, retryExpiryTime));
}
+ return fetchedCol;
}
ClusterState.CollectionRef getCollectionRef(String collection) {