You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2014/04/02 19:20:12 UTC
svn commit: r1584097 -
/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
Author: hossman
Date: Wed Apr 2 17:20:11 2014
New Revision: 1584097
URL: http://svn.apache.org/r1584097
Log:
SOLR-5795: harden leader check to log cleanly (no NPE) in transient situations when there is no leader due to election in progress
Modified:
lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java?rev=1584097&r1=1584096&r2=1584097&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/DocExpirationUpdateProcessorFactory.java Wed Apr 2 17:20:11 2014
@@ -23,7 +23,7 @@ import org.apache.solr.common.SolrExcept
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 DocExpirationUpdatePr
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);