mirror of https://github.com/apache/lucene.git
SOLR-7989: After a new leader is elected it should change it's state to ACTIVE even
if the last published state is something else git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1712753 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d1a16ff3c
commit
9343bc9cab
|
@ -325,9 +325,11 @@ Bug Fixes
|
|||
a race condition can cause that client to hang in blockUntilFinished.
|
||||
(Mark Miller, yonik)
|
||||
|
||||
|
||||
* SOLR-8215: Only active replicas should handle incoming requests against a collection (Varun Thacker)
|
||||
|
||||
* SOLR-7989: After a new leader is elected it should change it's state to ACTIVE even
|
||||
if the last published state is something else (Ishan Chattopadhyaya, Mark Miller via noble )
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.lucene.search.MatchAllDocsQuery;
|
|||
import org.apache.solr.cloud.overseer.OverseerAction;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
|
@ -107,6 +108,7 @@ class ShardLeaderElectionContextBase extends ElectionContext {
|
|||
private static Logger log = LoggerFactory
|
||||
.getLogger(ShardLeaderElectionContextBase.class);
|
||||
protected final SolrZkClient zkClient;
|
||||
protected ZkStateReader zkStateReader;
|
||||
protected String shardId;
|
||||
protected String collection;
|
||||
protected LeaderElector leaderElector;
|
||||
|
@ -119,6 +121,7 @@ class ShardLeaderElectionContextBase extends ElectionContext {
|
|||
+ "/leader_elect/" + shardId, ZkStateReader.getShardLeadersPath(
|
||||
collection, shardId), props, zkStateReader.getZkClient());
|
||||
this.leaderElector = leaderElector;
|
||||
this.zkStateReader = zkStateReader;
|
||||
this.zkClient = zkStateReader.getZkClient();
|
||||
this.shardId = shardId;
|
||||
this.collection = collection;
|
||||
|
@ -213,13 +216,28 @@ class ShardLeaderElectionContextBase extends ElectionContext {
|
|||
}
|
||||
|
||||
assert shardId != null;
|
||||
ZkNodeProps m = ZkNodeProps.fromKeyVals(Overseer.QUEUE_OPERATION,
|
||||
OverseerAction.LEADER.toLower(), ZkStateReader.SHARD_ID_PROP, shardId,
|
||||
ZkStateReader.COLLECTION_PROP, collection, ZkStateReader.BASE_URL_PROP,
|
||||
leaderProps.getProperties().get(ZkStateReader.BASE_URL_PROP),
|
||||
ZkStateReader.CORE_NAME_PROP,
|
||||
leaderProps.getProperties().get(ZkStateReader.CORE_NAME_PROP),
|
||||
ZkStateReader.STATE_PROP, Replica.State.ACTIVE.toString());
|
||||
|
||||
ZkNodeProps m;
|
||||
ClusterState clusterState = zkStateReader.getClusterState();
|
||||
Replica rep = (clusterState == null) ? null : clusterState.getReplica(collection,
|
||||
leaderProps.getStr(ZkStateReader.CORE_NODE_NAME_PROP));
|
||||
if (rep != null && rep.getState() != Replica.State.ACTIVE) {
|
||||
m = ZkNodeProps.fromKeyVals(Overseer.QUEUE_OPERATION, OverseerAction.STATE.toLower(),
|
||||
ZkStateReader.STATE_PROP, Replica.State.ACTIVE.toString(),
|
||||
ZkStateReader.SHARD_ID_PROP, shardId,
|
||||
ZkStateReader.COLLECTION_PROP, collection,
|
||||
ZkStateReader.BASE_URL_PROP, leaderProps.getProperties().get(ZkStateReader.BASE_URL_PROP),
|
||||
ZkStateReader.NODE_NAME_PROP, leaderProps.getProperties().get(ZkStateReader.NODE_NAME_PROP),
|
||||
ZkStateReader.CORE_NODE_NAME_PROP, leaderProps.getProperties().get(ZkStateReader.CORE_NODE_NAME_PROP),
|
||||
ZkStateReader.CORE_NAME_PROP, leaderProps.getProperties().get(ZkStateReader.CORE_NAME_PROP));
|
||||
Overseer.getInQueue(zkClient).offer(Utils.toJSON(m));
|
||||
}
|
||||
|
||||
m = ZkNodeProps.fromKeyVals(Overseer.QUEUE_OPERATION, OverseerAction.LEADER.toLower(),
|
||||
ZkStateReader.SHARD_ID_PROP, shardId,
|
||||
ZkStateReader.COLLECTION_PROP, collection,
|
||||
ZkStateReader.BASE_URL_PROP, leaderProps.getProperties().get(ZkStateReader.BASE_URL_PROP),
|
||||
ZkStateReader.CORE_NAME_PROP, leaderProps.getProperties().get(ZkStateReader.CORE_NAME_PROP));
|
||||
Overseer.getInQueue(zkClient).offer(Utils.toJSON(m));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue