This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch jira/solr16636_test
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/jira/solr16636_test by this
push:
new 34529c9f05e revert everything
34529c9f05e is described below
commit 34529c9f05ec067b435cc8094e203f5fe7b53d17
Author: Noble Paul <[email protected]>
AuthorDate: Thu Feb 23 18:19:49 2023 +1100
revert everything
---
.../processor/DistributedZkUpdateProcessor.java | 12 +--
.../apache/solr/common/cloud/ZkStateReader.java | 101 +--------------------
.../org/apache/solr/common/cloud/ClusterState.java | 8 --
3 files changed, 5 insertions(+), 116 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 c1eee8572c2..557f09fae28 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
@@ -168,16 +168,8 @@ public class DistributedZkUpdateProcessor extends
DistributedUpdateProcessor {
List<SolrCmdDistributor.Node> nodes = null;
Replica leaderReplica = null;
zkCheck();
- try {
- leaderReplica =
- zkController.getZkStateReader().getLeaderRetry(collection,
cloudDesc.getShardId());
- } catch (InterruptedException e) {
- Thread.interrupted();
- throw new SolrException(
- SolrException.ErrorCode.SERVICE_UNAVAILABLE,
- "Exception finding leader for shard " + cloudDesc.getShardId(),
- e);
- }
+ DocCollection c =
zkController.getZkStateReader().getClusterState().getCollection(collection);
+ leaderReplica =
ZkStateReader.getLeader(zkController.getZkStateReader().getClusterState().getLiveNodes(),
c, cloudDesc.getShardId());
isLeader = leaderReplica.getName().equals(cloudDesc.getCoreNodeName());
nodes = getCollectionUrls(collection, EnumSet.of(Replica.Type.TLOG,
Replica.Type.NRT), true);
diff --git
a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java
b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 693380bfbe5..dea4e589090 100644
---
a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++
b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -830,11 +830,6 @@ public class ZkStateReader implements SolrCloseable {
return cachedDocCollection;
}
- @Override
- public DocCollection getOrNull() {
- return cachedDocCollection;
- }
-
@Override
public boolean isLazilyLoaded() {
return true;
@@ -974,7 +969,7 @@ public class ZkStateReader implements SolrCloseable {
return props.getCoreUrl();
}
- public Replica getLeader(Set<String> liveNodes, DocCollection docCollection,
String shard) {
+ public static Replica getLeader(Set<String> liveNodes, DocCollection
docCollection, String shard) {
Replica replica = docCollection != null ? docCollection.getLeader(shard) :
null;
if (replica != null && liveNodes.contains(replica.getNodeName())) {
return replica;
@@ -1685,47 +1680,6 @@ public class ZkStateReader implements SolrCloseable {
}
}
- /**
- * fetch the collection that is already cached. This may return a null if it
is not already cached
- * This is an optimization to avoid fetching state if it is not modified.
this is particularly
- * true for PRS collections where state is rarely modified
- */
- private DocCollection fetchCachedCollection(String coll) {
- String collectionPath = DocCollection.getCollectionPath(coll);
- DocCollection c = null;
- ClusterState.CollectionRef ref = clusterState.getCollectionRef(coll);
- if (ref == null) return null;
- c = ref.getOrNull();
- if (c == null) return null;
- Stat stat = null;
- try {
- long start = System.currentTimeMillis();
- stat = zkClient.exists(collectionPath, null, false);
- long timeTaken = System.currentTimeMillis() - start;
- if(timeTaken > 5) {
- log.info("zkClient.exists({}): {}", collectionPath,timeTaken );
- }
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- return null;
- } catch (Exception e) {
- log.warn("unexpected exception: ",e);
- return null;
- }
- if (stat != null) {
- if (stat.getVersion() > c.getZNodeVersion()) return null;
- if (!c.isModified(stat.getVersion(), stat.getCversion())) {
- // we have the latest collection state
- return c;
- }
- if (c.isPerReplicaState() && c.getChildNodesVersion() <
stat.getCversion()) {
- // only PRS is modified. just fetch it and return the new collection
- return c.copyWith(PerReplicaStatesFetcher.fetch(collectionPath,
zkClient, null));
- }
- }
- return null;
- }
-
private DocCollection fetchCollectionState(String coll, Watcher watcher)
throws KeeperException, InterruptedException {
String collectionPath = DocCollection.getCollectionPath(coll);
@@ -1909,21 +1863,10 @@ public class ZkStateReader implements SolrCloseable {
public void waitForState(
final String collection, long wait, TimeUnit unit,
CollectionStatePredicate predicate)
throws InterruptedException, TimeoutException {
+
if (closed) {
throw new AlreadyClosedException();
}
- DocCollection coll = null;
- try {
- coll = getCollandLog(collection);
- } catch (Exception e) {
- log.warn("fetch threw exception",e);
- //do not do anything
- }
- if (coll != null && predicate.matches(liveNodes, coll)) {
- return;
- } else {
- log.info("registering actual watcher");
- }
final CountDownLatch latch = new CountDownLatch(1);
waitLatches.add(latch);
@@ -1938,12 +1881,7 @@ public class ZkStateReader implements SolrCloseable {
};
try {
- long start = System.currentTimeMillis();
registerCollectionStateWatcher(collection, watcher);
- long timeTaken = System.currentTimeMillis() - start;
- if(timeTaken>5) {
- log.info("registerCollectionStateWatcher {}ms", timeTaken);
- }
// wait for the watcher predicate to return true, or time out
if (!latch.await(wait, unit))
throw new TimeoutException(
@@ -1958,26 +1896,6 @@ public class ZkStateReader implements SolrCloseable {
}
}
- private DocCollection getCollandLog(String collection) {
- long start = System.currentTimeMillis();
- try {
- return fetchCachedCollection(collection);
- } finally {
- long time = System.currentTimeMillis() - start;
- if(time > 5) {
- StringBuilder sb = new StringBuilder();
- StackTraceElement[] st = new RuntimeException().getStackTrace();
- for (int i = 1; i < 5; i++) {
- StackTraceElement e = st[i];
-
sb.append(e.getMethodName()).append("@").append(e.getLineNumber()).append(" >
");
- }
-
- log.info("fetchCachedCollection. Waited {} callstack : {}", time, sb);
- }
-
- }
- }
-
/**
* Block until a Predicate returns true, or the wait times out
*
@@ -1996,21 +1914,13 @@ public class ZkStateReader implements SolrCloseable {
public DocCollection waitForState(
final String collection, long wait, TimeUnit unit,
Predicate<DocCollection> predicate)
throws InterruptedException, TimeoutException {
-
if (log.isDebugEnabled()) {
log.debug("Waiting up to {}ms for state {}", unit.toMillis(wait),
predicate);
}
if (closed) {
throw new AlreadyClosedException();
}
- DocCollection coll = null;
- try {
- coll = getCollandLog(collection);
- } catch (Exception e) {
- log.warn("fetch threw exception",e);
- //do not do anything
- }
- if (coll != null && predicate.test(coll)) return coll;
+
final CountDownLatch latch = new CountDownLatch(1);
waitLatches.add(latch);
AtomicReference<DocCollection> docCollection = new AtomicReference<>();
@@ -2024,12 +1934,7 @@ public class ZkStateReader implements SolrCloseable {
};
try {
- long start = System.currentTimeMillis();
registerDocCollectionWatcher(collection, watcher);
- long timeTaken = System.currentTimeMillis() - start;
- if(timeTaken>5) {
- log.info("registerCollectionStateWatcher {}ms", timeTaken);
- }
// wait for the watcher predicate to return true, or time out
if (!latch.await(wait, unit))
throw new TimeoutException(
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 22c14473f2c..cda0b66a9e6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -391,14 +391,6 @@ public class ClusterState implements JSONWriter.Writable {
protected final AtomicInteger gets = new AtomicInteger();
private final DocCollection coll;
- /**
- * return the collection if it is already loaded. lazy references may
return null if it is not
- * loaded already
- */
- public DocCollection getOrNull() {
- return coll;
- }
-
public int getCount() {
return gets.get();
}