mirror of https://github.com/apache/lucene.git
SOLR-5795: harden leader check to log cleanly (no NPE) in transient situations when there is no leader due to election in progress
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1584097 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a9e04127df
commit
80cce99ebc
|
@ -23,7 +23,7 @@ import org.apache.solr.common.SolrException;
|
|||
import static org.apache.solr.common.SolrException.ErrorCode.*;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
|
||||
import org.apache.solr.core.CloseHook;
|
||||
|
@ -469,7 +469,17 @@ public final class DocExpirationUpdateProcessorFactory
|
|||
|
||||
List<Slice> slices = new ArrayList<Slice>(zk.getClusterState().getActiveSlices(col));
|
||||
Collections.sort(slices, COMPARE_SLICES_BY_NAME);
|
||||
String leaderInCharge = slices.get(0).getLeader().getName();
|
||||
if (slices.isEmpty()) {
|
||||
log.error("Collection {} has no active Slices?", col);
|
||||
return false;
|
||||
}
|
||||
Replica firstSliceLeader = slices.get(0).getLeader();
|
||||
if (null == firstSliceLeader) {
|
||||
log.warn("Slice in charge of periodic deletes for {} does not currently have a leader",
|
||||
col);
|
||||
return false;
|
||||
}
|
||||
String leaderInCharge = firstSliceLeader.getName();
|
||||
String myCoreNodeName = desc.getCoreNodeName();
|
||||
|
||||
boolean inChargeOfDeletesRightNow = leaderInCharge.equals(myCoreNodeName);
|
||||
|
|
Loading…
Reference in New Issue