You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by tf...@apache.org on 2019/02/15 22:52:16 UTC

[lucene-solr] branch branch_8x updated: SOLR-13229: Cleanup replicasMetTragicEvent after all exceptions

This is an automated email from the ASF dual-hosted git repository.

tflobbe pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 3f0dd8a  SOLR-13229: Cleanup replicasMetTragicEvent after all exceptions
3f0dd8a is described below

commit 3f0dd8a70f07d3a00312788abae7c431eac3136c
Author: Tomas Fernandez Lobbe <tf...@apache.org>
AuthorDate: Wed Feb 6 16:43:47 2019 -0800

    SOLR-13229: Cleanup replicasMetTragicEvent after all exceptions
---
 solr/CHANGES.txt                                       |  2 ++
 .../src/java/org/apache/solr/cloud/ZkController.java   | 18 ++++++++++++------
 .../src/java/org/apache/solr/core/CoreContainer.java   | 11 +++++------
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1e68226..1b7a234 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -41,6 +41,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
 ----------------------
 
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 c84ba6b..fda5542 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 05a8c79..3dc1bb5 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;