megancarey commented on a change in pull request #2148:
URL: https://github.com/apache/lucene-solr/pull/2148#discussion_r549503500



##########
File path: solr/core/src/java/org/apache/solr/cloud/ZkController.java
##########
@@ -1609,12 +1611,41 @@ public void publish(final CoreDescriptor cd, final 
Replica.State state, boolean
       if (updateLastState) {
         cd.getCloudDescriptor().setLastPublished(state);
       }
-      overseerJobQueue.offer(Utils.toJSON(m));
+      DocCollection coll = zkStateReader.getCollection(collection);
+      if (forcePublish || sendToOverseer(coll, coreNodeName)) {
+        overseerJobQueue.offer(Utils.toJSON(m));
+      } else {
+//        if (log.isInfoEnabled()) {
+          //nocommit make this debug
+          log.info("bypassed overseer for message : {}", 
Utils.toJSONString(m));
+//        }
+        PerReplicaStates perReplicaStates = 
PerReplicaStates.fetch(coll.getZNode(), zkClient, coll.getPerReplicaStates());
+        PerReplicaStates.WriteOps ops = 
PerReplicaStates.WriteOps.flipState(coreNodeName, state, perReplicaStates);
+        PerReplicaStates.persist(ops, coll.getZNode(), zkClient);
+      }
     } finally {
       MDCLoggingContext.clear();
     }
   }
 
+  /**
+   * Whether a message needs to be sent to overseer or not
+   */
+  static boolean sendToOverseer(DocCollection coll, String replicaName) {
+    if (coll == null) return true;
+    if (coll.getStateFormat() < 2 || !coll.isPerReplicaState()) return true;
+    Replica r = coll.getReplica(replicaName);
+    if (r == null) return true;
+    Slice shard = coll.getSlice(r.slice);
+    if (shard == null) return true;//very unlikely
+    if (shard.getState() == Slice.State.RECOVERY) return true;
+    if (shard.getParent() != null) return true;
+    for (Slice slice : coll.getSlices()) {
+      if (Objects.equals(shard.getName(), slice.getParent())) return true;

Review comment:
       Won't this always be true since `shard` was picked from coll:slices list?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to