SOLR-8779: Fix missing InterruptedException handling in ZkStateReader

This commit is contained in:
Varun Thacker 2016-03-04 18:08:53 +05:30
parent ab35fafdd5
commit 21bf9c6e80
2 changed files with 22 additions and 12 deletions

View File

@ -265,6 +265,8 @@ Bug Fixes
* SOLR-8728: ReplicaAssigner throws NPE when a partial list of nodes are only participating in replica * SOLR-8728: ReplicaAssigner throws NPE when a partial list of nodes are only participating in replica
placement. splitshard should preassign nodes using rules, if rules are present (noble, Shai Erera) placement. splitshard should preassign nodes using rules, if rules are present (noble, Shai Erera)
* SOLR-8779: Fix missing InterruptedException handling in ZkStateReader.java (Varun Thacker)
Optimizations Optimizations
---------------------- ----------------------
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been * SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been

View File

@ -165,12 +165,10 @@ public class ZkStateReader implements Closeable {
} else { } else {
throw new ZooKeeperException(ErrorCode.INVALID_STATE, "No config data found at path: " + path); throw new ZooKeeperException(ErrorCode.INVALID_STATE, "No config data found at path: " + path);
} }
} } catch (KeeperException e) {
catch (KeeperException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e);
} } catch (InterruptedException e) {
catch (InterruptedException e) { Thread.currentThread().interrupt();
Thread.interrupted();
throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e); throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading config name for collection " + collection, e);
} }
@ -691,14 +689,17 @@ public class ZkStateReader implements Closeable {
this.aliases = ClusterState.load(data); this.aliases = ClusterState.load(data);
} }
public Map getClusterProps(){ public Map getClusterProps() {
try { try {
if (getZkClient().exists(ZkStateReader.CLUSTER_PROPS, true)) { if (getZkClient().exists(ZkStateReader.CLUSTER_PROPS, true)) {
return (Map) Utils.fromJSON(getZkClient().getData(ZkStateReader.CLUSTER_PROPS, null, new Stat(), true)) ; return (Map) Utils.fromJSON(getZkClient().getData(ZkStateReader.CLUSTER_PROPS, null, new Stat(), true)) ;
} else { } else {
return new LinkedHashMap(); return new LinkedHashMap();
} }
} catch (Exception e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVER_ERROR, "Thread interrupted. Error reading cluster properties", e);
} catch (KeeperException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading cluster properties", e); throw new SolrException(ErrorCode.SERVER_ERROR, "Error reading cluster properties", e);
} }
} }
@ -741,9 +742,13 @@ public class ZkStateReader implements Closeable {
LOG.warn("Race condition while trying to set a new cluster prop on current version [{}]", s.getVersion()); LOG.warn("Race condition while trying to set a new cluster prop on current version [{}]", s.getVersion());
//race condition //race condition
continue; continue;
} catch (Exception ex) { } catch (InterruptedException e) {
LOG.error("Error updating path [{}]", CLUSTER_PROPS, ex); Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVER_ERROR, "Error updating cluster property " + propertyName, ex); LOG.error("Thread Interrupted. Error updating path [{}]", CLUSTER_PROPS, e);
throw new SolrException(ErrorCode.SERVER_ERROR, "Thread Interrupted. Error updating cluster property " + propertyName, e);
} catch (KeeperException e) {
LOG.error("Error updating path [{}]", CLUSTER_PROPS, e);
throw new SolrException(ErrorCode.SERVER_ERROR, "Error updating cluster property " + propertyName, e);
} }
break; break;
} }
@ -766,8 +771,11 @@ public class ZkStateReader implements Closeable {
new ConfigData((Map<String, Object>) Utils.fromJSON(data), stat.getVersion()) : new ConfigData((Map<String, Object>) Utils.fromJSON(data), stat.getVersion()) :
null; null;
} }
} catch (KeeperException | InterruptedException e) { } catch (InterruptedException e) {
throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties",e) ; Thread.currentThread().interrupt();
throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties", e) ;
} catch (KeeperException e) {
throw new SolrException(ErrorCode.SERVER_ERROR,"Error reading security properties", e) ;
} }
return null; return null;
} }