SOLR-4795: Sub shard leader should not accept any updates from parent after it goes active

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1480113 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2013-05-07 22:02:13 +00:00
parent 27ef1eb203
commit 3ffb10b13e
4 changed files with 17 additions and 8 deletions

View File

@ -90,6 +90,9 @@ Bug Fixes
* SOLR-4616: HitRatio on caches is now exposed over JMX MBeans as a float.
(Greg Bowyer)
* SOLR-4795: Sub shard leader should not accept any updates from parent after
it goes active (shalin)
Other Changes
----------------------

View File

@ -322,7 +322,11 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
boolean localIsLeader = cloudDescriptor.isLeader();
if (DistribPhase.FROMLEADER == phase && localIsLeader && from != null) { // from will be null on log replay
String fromShard = req.getParams().get("distrib.from.parent");
if (fromShard != null) {
if (fromShard != null) {
if (!Slice.CONSTRUCTION.equals(mySlice.getState())) {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
"Request says it is coming from parent shard leader but we are not in construction state");
}
// shard splitting case -- check ranges to see if we are a sub-shard
Slice fromSlice = zkController.getClusterState().getCollection(collection).getSlice(fromShard);
DocRouter.Range parentRange = fromSlice.getRange();
@ -331,12 +335,12 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
"Request says it is coming from parent shard leader but parent hash range is not superset of my range");
}
} else {
log.error("Request says it is coming from leader, but we are the leader: " + req.getParamString());
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Request says it is coming from leader, but we are the leader");
} else {
log.error("Request says it is coming from leader, but we are the leader: " + req.getParamString());
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Request says it is coming from leader, but we are the leader");
}
}
}
if (isLeader && !localIsLeader) {
log.error("ClusterState says we are the leader, but locally we don't think so");
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "ClusterState says we are the leader, but locally we don't think so");

View File

@ -85,7 +85,8 @@ public class ChaosMonkeyShardSplitTest extends ShardSplitTest {
indexThread = new Thread() {
@Override
public void run() {
for (int id = 101; id < atLeast(401); id++) {
int max = atLeast(401);
for (int id = 101; id < max; id++) {
try {
indexAndUpdateCount(ranges, docCounts, id);
Thread.sleep(atLeast(25));

View File

@ -110,7 +110,8 @@ public class ShardSplitTest extends BasicDistributedZkTest {
Thread indexThread = new Thread() {
@Override
public void run() {
for (int id = 101; id < atLeast(401); id++) {
int max = atLeast(401);
for (int id = 101; id < max; id++) {
try {
indexAndUpdateCount(ranges, docCounts, id);
Thread.sleep(atLeast(25));