mirror of https://github.com/apache/lucene.git
SOLR-7248: In legacyCloud=false mode we should check if the core was hosted on the same node before registering it
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1668931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5ac2c238cf
commit
2cba11bfa6
|
@ -286,6 +286,9 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-7134: Replication can still cause index corruption. (Mark Miller, shalin, Mike Drob)
|
* 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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -1516,21 +1516,33 @@ public final class ZkController {
|
||||||
CloudDescriptor cloudDesc = cd.getCloudDescriptor();
|
CloudDescriptor cloudDesc = cd.getCloudDescriptor();
|
||||||
String coreNodeName = cloudDesc.getCoreNodeName();
|
String coreNodeName = cloudDesc.getCoreNodeName();
|
||||||
assert coreNodeName != null;
|
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);
|
long endTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);
|
||||||
String errMessage= null;
|
String errMessage = null;
|
||||||
for (; System.nanoTime()<endTime; ) {
|
while (System.nanoTime() < endTime) {
|
||||||
Thread.sleep(100);
|
|
||||||
errMessage = null;
|
|
||||||
Slice slice = zkStateReader.getClusterState().getSlice(cd.getCollectionName(), cloudDesc.getShardId());
|
Slice slice = zkStateReader.getClusterState().getSlice(cd.getCollectionName(), cloudDesc.getShardId());
|
||||||
if (slice == null) {
|
if (slice == null) {
|
||||||
errMessage = "Invalid slice : " + cloudDesc.getShardId();
|
errMessage = "Invalid slice : " + cloudDesc.getShardId();
|
||||||
continue;
|
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 = " no_such_replica in clusterstate ,replicaName : " + coreNodeName;
|
if (errMessage == null) {
|
||||||
throw new SolrException(ErrorCode.SERVER_ERROR,errMessage + "state : "+ zkStateReader.getClusterState().getCollection(cd.getCollectionName()));
|
errMessage = "replica " + coreNodeName + " is not present in cluster state";
|
||||||
|
}
|
||||||
|
throw new SolrException(ErrorCode.SERVER_ERROR, errMessage + ". state : "+ zkStateReader.getClusterState().getCollection(cd.getCollectionName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue