You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2014/04/15 21:28:45 UTC
svn commit: r1587702 - in /lucene/dev/trunk/solr: CHANGES.txt
core/src/java/org/apache/solr/cloud/ElectionContext.java
Author: markrmiller
Date: Tue Apr 15 19:28:45 2014
New Revision: 1587702
URL: http://svn.apache.org/r1587702
Log:
SOLR-5904: ElectionContext can cancel an election when it should not if there was an exception while trying to register as the leader.
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1587702&r1=1587701&r2=1587702&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Apr 15 19:28:45 2014
@@ -94,6 +94,13 @@ Upgrading from Solr 4.8
Detailed Change List
----------------------
+Bug Fixes
+----------------------
+
+* SOLR-5904: ElectionContext can cancel an election when it should not if there
+ was an exception while trying to register as the leader.
+ (Mark Miller, Alan Woodward)
+
Other Changes
---------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1587702&r1=1587701&r2=1587702&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java Tue Apr 15 19:28:45 2014
@@ -286,62 +286,26 @@ final class ShardLeaderElectionContext e
+ ZkCoreNodeProps.getCoreUrl(leaderProps) + " " + shardId);
core.getCoreDescriptor().getCloudDescriptor().setLeader(true);
}
- boolean success = false;
+
try {
super.runLeaderProcess(weAreReplacement, 0);
- success = true;
} catch (Exception e) {
SolrException.log(log, "There was a problem trying to register as the leader", e);
try (SolrCore core = cc.getCore(coreName)) {
if (core == null) {
- throw new SolrException(ErrorCode.SERVER_ERROR,
- "Fatal Error, SolrCore not found:" + coreName + " in "
- + cc.getCoreNames());
+ log.debug("SolrCore not found:" + coreName + " in " + cc.getCoreNames());
+ return;
}
core.getCoreDescriptor().getCloudDescriptor().setLeader(false);
- // we could not publish ourselves as leader - rejoin election
+ // we could not publish ourselves as leader - try and rejoin election
rejoinLeaderElection(leaderSeqPath, core);
- } finally {
- if (!success)
- cancelElection();
- }
- }
-
- }
-
- private boolean areAnyOtherReplicasActive(ZkController zkController,
- ZkNodeProps leaderProps, String collection, String shardId) {
- ClusterState clusterState = zkController.getZkStateReader()
- .getClusterState();
- Map<String,Slice> slices = clusterState.getSlicesMap(collection);
- Slice slice = slices.get(shardId);
- if (!slice.getState().equals(Slice.ACTIVE)) {
- //Return false if the Slice is not active yet.
- return false;
- }
- Map<String,Replica> replicasMap = slice.getReplicasMap();
- for (Map.Entry<String,Replica> shard : replicasMap.entrySet()) {
- String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
- // System.out.println("state:"
- // + state
- // + shard.getValue().get(ZkStateReader.NODE_NAME_PROP)
- // + " live: "
- // + clusterState.liveNodesContain(shard.getValue().get(
- // ZkStateReader.NODE_NAME_PROP)));
- if (state.equals(ZkStateReader.ACTIVE)
- && clusterState.liveNodesContain(shard.getValue().getStr(
- ZkStateReader.NODE_NAME_PROP))
- && !new ZkCoreNodeProps(shard.getValue()).getCoreUrl().equals(
- new ZkCoreNodeProps(leaderProps).getCoreUrl())) {
- return true;
}
}
- return false;
}
private void waitForReplicasToComeUp(boolean weAreReplacement, int timeoutms) throws InterruptedException {