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 2016/01/18 10:47:14 UTC

svn commit: r1725209 - in /lucene/dev/branches/branch_5x/solr: CHANGES.txt core/src/java/org/apache/solr/cloud/ZkController.java

Author: shaie
Date: Mon Jan 18 09:47:14 2016
New Revision: 1725209

URL: http://svn.apache.org/viewvc?rev=1725209&view=rev
Log:
SOLR-8561: Add fallback to ZkController.getLeaderProps for a mixed 5.4-pre-5.4 deployments

Modified:
    lucene/dev/branches/branch_5x/solr/CHANGES.txt
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1725209&r1=1725208&r2=1725209&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Mon Jan 18 09:47:14 2016
@@ -350,6 +350,11 @@ Bug Fixes
 
 * SOLR-8418: Adapt to changes in LUCENE-6590 for use of boosts with MLTHandler and
   Simple/CloudMLTQParser (Jens Wille, Ramkumar Aiyengar)
+  
+* SOLR-8561: Doing a rolling upgrade to 5.4.0 fails because the new nodes cannot find the 
+  shard leader properties where they expect. This bug was first introduced in 5.4.0 and a
+  fallback was added so that the leader properties are searched in both the old location
+  and the new one. (Shai Erera)
 
 New Features
 ----------------------

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1725209&r1=1725208&r2=1725209&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/ZkController.java Mon Jan 18 09:47:14 2016
@@ -1021,11 +1021,8 @@ public final class ZkController {
     Exception exp = null;
     while (iterCount-- > 0) {
       try {
-        byte[] data = zkClient.getData(
-            ZkStateReader.getShardLeadersPath(collection, slice), null, null,
-            true);
-        ZkCoreNodeProps leaderProps = new ZkCoreNodeProps(
-            ZkNodeProps.load(data));
+        byte[] data = getLeaderPropsWithFallback(collection, slice);
+        ZkCoreNodeProps leaderProps = new ZkCoreNodeProps(ZkNodeProps.load(data));
         return leaderProps;
       } catch (InterruptedException e) {
         throw e;
@@ -1046,6 +1043,17 @@ public final class ZkController {
     throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Could not get leader props", exp);
   }
 
+  private byte[] getLeaderPropsWithFallback(String collection, String slice) throws KeeperException, InterruptedException {
+    final String leaderPath = ZkStateReader.getShardLeadersPath(collection, slice);
+    try {
+      return zkClient.getData(leaderPath, null, null, true);
+    } catch (final KeeperException.NoNodeException e) {
+      // If the original leader node isn't found, fallback to a pre-5.4 format, where the leader props were set
+      // on the parent node (in case the current leader is a pre-5.4 Solr instance).
+      final String parentLeaderPath = new org.apache.hadoop.fs.Path(leaderPath).getParent().toString();
+      return zkClient.getData(parentLeaderPath, null, null, true);
+    }
+  }
 
   private void joinElection(CoreDescriptor cd, boolean afterExpiration, boolean joinAtHead)
       throws InterruptedException, KeeperException, IOException {