Skip to content

Commit

Permalink
SAI-5162: Add sysprop solrcloud.publishDownOnStart to controller wh…
Browse files Browse the repository at this point in the history
…ether publish down on node start or not (#233)

* Add sysprop `solrcloud.skipPublishDownOnStart` to controller whether publish down on node start or not

* Use RTimer instead

* Added timer for the whole publish down ops, including persist ops

* ./gradlew tidy

* Changed solrcloud.skipPublishDownOnStart to solrcloud.publishDownOnStart

which means if such flag is NOT defined (hence solrcloud.publishDownOnStart=false), then by default it will bypass publishAndWaitForDownStates
  • Loading branch information
patsonluk committed Nov 12, 2024
1 parent b3d5916 commit 35a4098
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion solr/core/src/java/org/apache/solr/cloud/ZkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,8 @@ private void init() {
}

Stat stat = zkClient.exists(ZkStateReader.LIVE_NODES_ZKNODE, null, true);
if (stat != null && stat.getNumChildren() > 0) {
boolean publishDownOnStart = Boolean.getBoolean("solrcloud.publishDownOnStart");
if (stat != null && stat.getNumChildren() > 0 && publishDownOnStart) {
publishAndWaitForDownStates();
}

Expand Down Expand Up @@ -2901,11 +2902,15 @@ public boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) {
* @return the names of the collections that have replicas on the given node
*/
public Collection<String> publishNodeAsDown(String nodeName) {
final RTimer publishDownTimer = new RTimer();
log.info("Publish node={} as DOWN", nodeName);

ClusterState clusterState = getClusterState();
final RTimer zkFetchTimer = new RTimer();
Map<String, List<Replica>> replicasPerCollectionOnNode =
clusterState.getReplicaNamesPerCollectionOnNode(nodeName);
long zkFetchDuration = (long) zkFetchTimer.getTime();
log.info("Spent {} ms on ClusterState#getReplicaNamesPerCollectionOnNode", zkFetchDuration);
if (distributedClusterStateUpdater.isDistributedStateUpdate()) {
// Note that with the current implementation, when distributed cluster state updates are
// enabled, we mark the node down synchronously from this thread, whereas the Overseer cluster
Expand Down Expand Up @@ -2958,6 +2963,9 @@ public Collection<String> publishNodeAsDown(String nodeName) {
log.warn("Could not publish node as down: ", e);
}
}
long publishDownDuration = (long) publishDownTimer.getTime();
log.info("Spent {} ms on ZKController#publishNodeAsDown", publishDownDuration);

return replicasPerCollectionOnNode.keySet();
}

Expand Down

0 comments on commit 35a4098

Please sign in to comment.