lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1668931 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/cloud/ZkController.java
Date Tue, 24 Mar 2015 16:35:31 GMT
Author: varun
Date: Tue Mar 24 16:35:30 2015
New Revision: 1668931

URL: http://svn.apache.org/r1668931
Log:
SOLR-7248: In legacyCloud=false mode we should check if the core was hosted on the same node
before registering it

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

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1668931&r1=1668930&r2=1668931&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Mar 24 16:35:30 2015
@@ -286,6 +286,9 @@ Bug Fixes
 
 * SOLR-7134: Replication can still cause index corruption. (Mark Miller, shalin, Mike Drob)
 
+* SOLR-7248: In legacyCloud=false mode we should check if the core was hosted on the same
node before registering it
+  (Varun Thacker, Noble Paul, Mark Miller)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1668931&r1=1668930&r2=1668931&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/ZkController.java Tue Mar 24
16:35:30 2015
@@ -1516,21 +1516,33 @@ public final class ZkController {
       CloudDescriptor cloudDesc = cd.getCloudDescriptor();
       String coreNodeName = cloudDesc.getCoreNodeName();
       assert coreNodeName != null;
-      if (cloudDesc.getShardId() == null) throw new SolrException(ErrorCode.SERVER_ERROR
,"No shard id for :" + cd);
+      if (cloudDesc.getShardId() == null) {
+        throw new SolrException(ErrorCode.SERVER_ERROR ,"No shard id for :" + cd);
+      }
       long endTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);
-      String errMessage= null;
-      for (; System.nanoTime()<endTime; ) {
-        Thread.sleep(100);
-        errMessage = null;
+      String errMessage = null;
+      while (System.nanoTime() < endTime) {
         Slice slice = zkStateReader.getClusterState().getSlice(cd.getCollectionName(), cloudDesc.getShardId());
         if (slice == null) {
           errMessage = "Invalid slice : " + cloudDesc.getShardId();
           continue;
         }
-        if (slice.getReplica(coreNodeName) != null) return;
+        if (slice.getReplica(coreNodeName) != null) {
+          Replica replica = slice.getReplica(coreNodeName);
+          String baseUrl = replica.getStr(BASE_URL_PROP);
+          String coreName = replica.getStr(CORE_NAME_PROP);
+          if (baseUrl.equals(this.baseURL) && coreName.equals(cd.getName())) {
+            return;
+          } else {
+            errMessage = "replica with coreNodeName " + coreNodeName + " exists but with
a different name or base_url";
+          }
+        }
+        Thread.sleep(100);
+      }
+      if (errMessage == null) {
+        errMessage = "replica " + coreNodeName + " is not present in cluster state";
       }
-      if(errMessage == null)  errMessage = " no_such_replica in clusterstate ,replicaName
:  " + coreNodeName;
-      throw new SolrException(ErrorCode.SERVER_ERROR,errMessage + "state : "+ zkStateReader.getClusterState().getCollection(cd.getCollectionName()));
+      throw new SolrException(ErrorCode.SERVER_ERROR, errMessage + ". state : "+ zkStateReader.getClusterState().getCollection(cd.getCollectionName()));
     }
   }
 



Mime
View raw message