SOLR-11478: Solr should remove itself from live_nodes in zk immediately on shutdown

This commit is contained in:
Cao Manh Dat 2017-10-17 17:35:00 +07:00
parent 283ffef9e2
commit 57e976341b
3 changed files with 23 additions and 0 deletions

View File

@ -61,6 +61,10 @@ Optimizations
* SOLR-11443: Remove the usage of workqueue for Overseer. (Cao Manh Dat, Scott Blum) * SOLR-11443: Remove the usage of workqueue for Overseer. (Cao Manh Dat, Scott Blum)
Other Changes
----------------------
* SOLR-11478: Solr should remove itself from live_nodes in zk immediately on shutdown. (Cao Manh Dat)
================== 7.1.0 ================== ================== 7.1.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -976,6 +976,20 @@ public class ZkController {
zkClient.multi(ops, true); zkClient.multi(ops, true);
} }
public void removeEphemeralLiveNode() throws KeeperException, InterruptedException {
if (zkRunOnly) {
return;
}
String nodeName = getNodeName();
String nodePath = ZkStateReader.LIVE_NODES_ZKNODE + "/" + nodeName;
String nodeAddedPath = ZkStateReader.SOLR_AUTOSCALING_NODE_ADDED_PATH + "/" + nodeName;
log.info("Remove node as live in ZooKeeper:" + nodePath);
List<Op> ops = new ArrayList<>(2);
ops.add(Op.delete(nodePath, -1));
ops.add(Op.delete(nodeAddedPath, -1));
zkClient.multi(ops, true);
}
public String getNodeName() { public String getNodeName() {
return nodeName; return nodeName;
} }

View File

@ -747,6 +747,11 @@ public class CoreContainer {
if (isZooKeeperAware()) { if (isZooKeeperAware()) {
cancelCoreRecoveries(); cancelCoreRecoveries();
zkSys.zkController.publishNodeAsDown(zkSys.zkController.getNodeName()); zkSys.zkController.publishNodeAsDown(zkSys.zkController.getNodeName());
try {
zkSys.zkController.removeEphemeralLiveNode();
} catch (Exception e) {
log.warn("Error removing live node. Continuing to close CoreContainer", e);
}
if (metricManager != null) { if (metricManager != null) {
metricManager.closeReporters(SolrMetricManager.getRegistryName(SolrInfoBean.Group.cluster)); metricManager.closeReporters(SolrMetricManager.getRegistryName(SolrInfoBean.Group.cluster));
} }