Skip to content

Apache Lucene open-source search software

SOLR-13229: Cleanup replicasMetTragicEvent after all exceptions

Tomas Fernandez Lobbe8ac34c2d6d10
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 112d70fa0b4..182c0067bf6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -59,6 +59,8 @@ Bug Fixes
* SOLR-12330: 500 error code on json.facet syntax errors (Munendra S N, Mikhail Khludnev)
+* SOLR-13229: Cleanup replicasMetTragicEvent after all types of exception (Tomás Fernández Löbbe)
+
Improvements
----------------------
* SOLR-12999: Index replication could delete segments before downloading segments from master if there is not enough
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index c84ba6b3ee8..fda5542be43 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -628,7 +628,14 @@ public class ZkController implements Closeable {
assert ObjectReleaseTracker.release(this);
}
+ /**
+ * Best effort to give up the leadership of a shard in a core after hitting a tragic exception
+ * @param cd The current core descriptor
+ * @param tragicException The tragic exception from the {@code IndexWriter}
+ */
public void giveupLeadership(CoreDescriptor cd, Throwable tragicException) {
+ assert tragicException != null;
+ assert cd != null;
DocCollection dc = getClusterState().getCollectionOrNull(cd.getCollectionName());
if (dc == null) return;
@@ -666,13 +673,12 @@ public class ZkController implements Closeable {
props.put(ZkStateReader.REPLICA_TYPE, cd.getCloudDescriptor().getReplicaType().name().toUpperCase(Locale.ROOT));
props.put(CoreAdminParams.NODE, getNodeName());
getOverseerCollectionQueue().offer(Utils.toJSON(new ZkNodeProps(props)));
- } catch (KeeperException e) {
- log.info("Met exception on give up leadership for {}", key, e);
- replicasMetTragicEvent.remove(key);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.info("Met exception on give up leadership for {}", key, e);
+ } catch (Exception e) {
+ // Exceptions are not bubbled up. giveupLeadership is best effort, and is only called in case of some other
+ // unrecoverable error happened
+ log.error("Met exception on give up leadership for {}", key, e);
replicasMetTragicEvent.remove(key);
+ SolrZkClient.checkInterrupted(e);
}
}
}
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 05a8c79c5cc..3dc1bb547ce 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -1867,8 +1867,9 @@ public class CoreContainer {
}
/**
- * @param solrCore te core against which we check if there has been a tragic exception
- * @return whether this solr core has tragic exception
+ * @param solrCore the core against which we check if there has been a tragic exception
+ * @return whether this Solr core has tragic exception
+ * @see org.apache.lucene.index.IndexWriter#getTragicException()
*/
public boolean checkTragicException(SolrCore solrCore) {
Throwable tragicException;
@@ -1879,10 +1880,8 @@ public class CoreContainer {
tragicException = e;
}
- if (tragicException != null) {
- if (isZooKeeperAware()) {
- getZkController().giveupLeadership(solrCore.getCoreDescriptor(), tragicException);
- }
+ if (tragicException != null && isZooKeeperAware()) {
+ getZkController().giveupLeadership(solrCore.getCoreDescriptor(), tragicException);
}
return tragicException != null;