You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/07/01 09:00:45 UTC
svn commit: r1606997 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/core/ solr/core/src/java/org/apache/solr/cloud/
solr/core/src/test/org/apache/solr/cloud/
Author: shalin
Date: Tue Jul 1 07:00:44 2014
New Revision: 1606997
URL: http://svn.apache.org/r1606997
Log:
SOLR-6159: A ZooKeeper session expiry during setup can keep LeaderElector from joining elections
Added:
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java
- copied unchanged from r1606996, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestLeaderElectionZkExpiry.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1606997&r1=1606996&r2=1606997&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue Jul 1 07:00:44 2014
@@ -78,6 +78,9 @@ Bug Fixes
* SOLR-6211: TrieDateField doesn't default to omitNorms=true. (Michael Ryan, Steve Rowe)
+* SOLR-6159: A ZooKeeper session expiry during setup can keep LeaderElector from joining elections.
+ (Steven Bower, shalin)
+
Other Changes
---------------------
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java?rev=1606997&r1=1606996&r2=1606997&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java Tue Jul 1 07:00:44 2014
@@ -51,7 +51,7 @@ public abstract class ElectionContext {
final ZkNodeProps leaderProps;
final String id;
final String leaderPath;
- String leaderSeqPath;
+ volatile String leaderSeqPath;
private SolrZkClient zkClient;
public ElectionContext(final String coreNodeName,
@@ -66,12 +66,16 @@ public abstract class ElectionContext {
public void close() {}
public void cancelElection() throws InterruptedException, KeeperException {
- try {
- log.info("canceling election {}",leaderSeqPath );
- zkClient.delete(leaderSeqPath, -1, true);
- } catch (NoNodeException e) {
- // fine
- log.warn("cancelElection did not find election node to remove {}" ,leaderSeqPath);
+ if( leaderSeqPath != null ){
+ try {
+ log.info("canceling election {}",leaderSeqPath );
+ zkClient.delete(leaderSeqPath, -1, true);
+ } catch (NoNodeException e) {
+ // fine
+ log.warn("cancelElection did not find election node to remove {}" ,leaderSeqPath);
+ }
+ } else {
+ log.warn("cancelElection skipped as this context has not been initialized");
}
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java?rev=1606997&r1=1606996&r2=1606997&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java Tue Jul 1 07:00:44 2014
@@ -298,6 +298,7 @@ public class LeaderElector {
// we must have failed in creating the election node - someone else must
// be working on it, lets try again
if (tries++ > 20) {
+ context = null;
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"", e);
}
@@ -372,10 +373,10 @@ public class LeaderElector {
*/
public void setup(final ElectionContext context) throws InterruptedException,
KeeperException {
- this.context = context;
String electZKPath = context.electionPath + LeaderElector.ELECTION_NODE;
zkCmdExecutor.ensureExists(electZKPath, zkClient);
+ this.context = context;
}
/**