From 5dfb49986ec46cb279b6279f83e34e6e34df02df Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 6 Jan 2014 04:37:48 +0000 Subject: [PATCH] SOLR-5608: Don't allow a closed SolrCore to publish state to ZooKeeper. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1555659 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../org/apache/solr/cloud/ZkController.java | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index da4af08cf41..cb7f0888ac4 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -341,6 +341,9 @@ Bug Fixes * SOLR-5564: hl.maxAlternateFieldLength should apply to original field when fallback is attempted (janhoy) +* SOLR-5608: Don't allow a closed SolrCore to publish state to ZooKeeper. + (Mark Miller, Shawn Heisey) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 7da73667b3d..9a4fd134b43 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -982,10 +982,27 @@ public final class ZkController { publish(cd, state, true); } + public void publish(final CoreDescriptor cd, final String state, boolean updateLastState) throws KeeperException, InterruptedException { + publish(cd, state, true, false); + } + /** * Publish core state to overseer. */ - public void publish(final CoreDescriptor cd, final String state, boolean updateLastState) throws KeeperException, InterruptedException { + public void publish(final CoreDescriptor cd, final String state, boolean updateLastState, boolean forcePublish) throws KeeperException, InterruptedException { + if (!forcePublish) { + SolrCore core = cc.getCore(cd.getName()); + if (core == null) { + return; + } + try { + if (core.isClosed()) { + return; + } + } finally { + core.close(); + } + } log.info("publishing core={} state={}", cd.getName(), state); //System.out.println(Thread.currentThread().getStackTrace()[3]); Integer numShards = cd.getCloudDescriptor().getNumShards(); @@ -1341,7 +1358,7 @@ public final class ZkController { cloudDesc.setCoreNodeName(coreNodeName); } - publish(cd, ZkStateReader.DOWN, false); + publish(cd, ZkStateReader.DOWN, false, true); } catch (KeeperException e) { log.error("", e); throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);