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/03/12 02:42:09 UTC

[lucene-solr] branch reference_impl updated: @1460 Fix a couple NPE possibilities. Finally. Let's load test.

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


The following commit(s) were added to refs/heads/reference_impl by this push:
     new 5d7e5aa  @1460 Fix a couple NPE possibilities. Finally. Let's load test.
5d7e5aa is described below

commit 5d7e5aac899791930137435cbadc9f9b97ac5712
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Mar 11 20:41:45 2021 -0600

    @1460 Fix a couple NPE possibilities. Finally. Let's load test.
    
    Took 19 minutes
---
 .../apache/solr/cloud/overseer/ZkStateWriter.java  | 31 ++++++----------------
 .../apache/solr/common/cloud/ZkStateReader.java    |  8 +++---
 2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
index 3c247bc..e62824b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java
@@ -350,34 +350,18 @@ public class ZkStateWriter {
 
             collState.collLock.lock();
             try {
-              //                if (collection == null) {
-              //                  Collection<ClusterState.CollectionRef> colls = cs.getCollectionStates().values();
-              //                  log.info("look for collection for id={} in {}}", id, cs.getCollectionStates().keySet());
-              //
-              //                  for (ClusterState.CollectionRef docCollectionRef : colls) {
-              //                    DocCollection docCollection = docCollectionRef.get();
-              //                    if (docCollection == null) {
-              //                      log.info("docCollection={}", docCollection);
-              //                    }
-              //                    if (docCollection.getId() == collectionId) {
-              //                      collection = docCollection.getName();
-              //                      break;
-              //                    }
-              //                  }
-              //                  if (collection == null) {
-              //                    continue;
-              //                  }
-              //                }
               String collection = entry.getKey();
+              ZkNodeProps updates = stateUpdates.get(collection);
+              if (updates == null) {
+                updates = new ZkNodeProps();
+                stateUpdates.put(collection, updates);
+              }
+
               for (StateUpdate state : entry.getValue()) {
 
                 String setState = Replica.State.shortStateToState(state.state).toString();
 
-                ZkNodeProps updates = stateUpdates.get(collection);
-                if (updates == null) {
-                  updates = new ZkNodeProps();
-                  stateUpdates.put(collection, updates);
-                }
+
                 Integer ver = trackVersions.get(collection);
                 if (ver == null) {
                   ver = 0;
@@ -446,6 +430,7 @@ public class ZkStateWriter {
           for (Map.Entry<String,List<StateUpdate>> update : collStateUpdates.entrySet()) {
 
             String coll = update.getKey();
+            dirtyState.add(coll);
             Integer ver = trackVersions.get(coll);
             if (ver == null) {
               ver = 0;
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 5fd312b..1454dcb 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -1016,7 +1016,7 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
    * Get shard leader properties, with retry if none exist.
    */
   public Replica getLeaderRetry(String collection, String shard, int timeout, boolean mustBeLive) throws InterruptedException, TimeoutException {
-    DocCollection coll = clusterState.get(collection).get();
+    DocCollection coll = getCollectionOrNull(collection);
     if (coll != null) {
       Slice slice = coll.getSlice(shard);
       if (slice  != null) {
@@ -1055,7 +1055,7 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
         return false;
       });
     } catch (TimeoutException e) {
-      coll = clusterState.get(collection).get();
+      coll = getCollectionOrNull(collection);
       throw new TimeoutException("No registered leader was found after waiting for "
           + timeout + "ms " + ", collection: " + collection + " slice: " + shard + " saw state=" + clusterState.get(collection)
           + " with live_nodes=" + liveNodes + " zkLeaderNode=" + (coll == null ? "null collection" : getLeaderProps(collection, coll.getId(), shard)));
@@ -1064,7 +1064,7 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
     Replica leader = returnLeader.get();
 
     if (leader == null) {
-      coll = clusterState.get(collection).get();
+      coll = getCollectionOrNull(collection);
       throw new SolrException(ErrorCode.SERVER_ERROR, "No registered leader was found "
           + "collection: " + collection + " slice: " + shard + " saw state=" + clusterState.get(collection)
           + " with live_nodes=" + liveNodes + " zkLeaderNode=" + getLeaderProps(collection, coll.getId(), shard));
@@ -2143,7 +2143,7 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
     registerDocCollectionWatcher(collection, wrapper);
     registerLiveNodesListener(wrapper);
 
-    DocCollection state = clusterState.get(collection).get();
+    DocCollection state = getCollectionOrNull(collection);
     if (stateWatcher.onStateChanged(liveNodes, state) == true) {
       removeCollectionStateWatcher(collection, stateWatcher);
     }