SOLR-5593: Replicas should accept the last updates from a leader that has just lost it's connection to ZooKeeper.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1565049 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-02-06 02:38:00 +00:00
parent c039f73cde
commit a2bf844c90
2 changed files with 28 additions and 5 deletions

View File

@ -270,6 +270,9 @@ Bug Fixes
* SOLR-5598: LanguageIdentifierUpdateProcessor ignores all but the first value
of multiValued string fields. (Andreas Hubold, Vitaliy Zhovtyuk via shalin)
* SOLR-5593: Replicas should accept the last updates from a leader that has just
lost it's connection to ZooKeeper. (Christine Poerschke via Mark Miller)
Optimizations
----------------------

View File

@ -228,6 +228,19 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
}
DistribPhase phase =
DistribPhase.parseParam(req.getParams().get(DISTRIB_UPDATE_PARAM));
if (DistribPhase.FROMLEADER == phase && !couldIbeSubShardLeader(coll)) {
if (req.getCore().getCoreDescriptor().getCloudDescriptor().isLeader()) {
// locally we think we are leader but the request says it came FROMLEADER
// that could indicate a problem, let the full logic below figure it out
} else {
isLeader = false; // we actually might be the leader, but we don't want leader-logic for these types of updates anyway.
forwardToLeader = false;
return nodes;
}
}
String shardId = slice.getName();
@ -251,9 +264,6 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
}
DistribPhase phase =
DistribPhase.parseParam(req.getParams().get(DISTRIB_UPDATE_PARAM));
doDefensiveChecks(phase);
// if request is coming from another collection then we want it to be sent to all replicas
@ -314,11 +324,21 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
return nodes;
}
private boolean couldIbeSubShardLeader(DocCollection coll) {
// Could I be the leader of a shard in "construction/recovery" state?
String myShardId = req.getCore().getCoreDescriptor().getCloudDescriptor()
.getShardId();
Slice mySlice = coll.getSlice(myShardId);
String state = mySlice.getState();
return (Slice.CONSTRUCTION.equals(state) || Slice.RECOVERY.equals(state));
}
private boolean amISubShardLeader(DocCollection coll, Slice parentSlice, String id, SolrInputDocument doc) throws InterruptedException {
// Am I the leader of a shard in "construction" state?
// Am I the leader of a shard in "construction/recovery" state?
String myShardId = req.getCore().getCoreDescriptor().getCloudDescriptor().getShardId();
Slice mySlice = coll.getSlice(myShardId);
if (Slice.CONSTRUCTION.equals(mySlice.getState()) || Slice.RECOVERY.equals(mySlice.getState())) {
String state = mySlice.getState();
if (Slice.CONSTRUCTION.equals(state) || Slice.RECOVERY.equals(state)) {
Replica myLeader = zkController.getZkStateReader().getLeaderRetry(collection, myShardId);
boolean amILeader = myLeader.getName().equals(
req.getCore().getCoreDescriptor().getCloudDescriptor()