From ed05debb4e223e07aeeccdc0a802b8c2a514ba23 Mon Sep 17 00:00:00 2001 From: markrmiller Date: Fri, 17 Feb 2017 11:29:19 -0500 Subject: [PATCH] SOLR-9846: Overseer is not always closed after being started. --- solr/CHANGES.txt | 1 + .../src/java/org/apache/solr/cloud/ElectionContext.java | 6 ++++++ .../src/java/org/apache/solr/cloud/LeaderElector.java | 1 + .../src/java/org/apache/solr/cloud/ZkController.java | 9 ++++----- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index f17018dceb5..19157ba58e5 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -165,6 +165,7 @@ Bug Fixes * SOLR-10141: Upgrade to Caffeine 2.3.5 since v1.0.1 contributed to BlockCache corruption because the removal listener was called more than once for some items and not at all for other items. (Ben Manes, yonik) +* SOLR-9846: Overseer is not always closed after being started. (Mark Miller) Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java index b3cd58566d9..3db6950155d 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java +++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java @@ -484,6 +484,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { public void checkLIR(String coreName, boolean allReplicasInLine) throws InterruptedException, KeeperException, IOException { if (allReplicasInLine) { + log.info("Found all replicas participating in election, clear LIR"); // SOLR-8075: A bug may allow the proper leader to get marked as LIR DOWN and // if we are marked as DOWN but were able to become the leader, we remove // the DOWN entry here so that we don't fail publishing ACTIVE due to being in LIR. @@ -752,6 +753,11 @@ final class OverseerElectionContext extends ElectionContext { super.cancelElection(); overseer.close(); } + + @Override + public void close() { + overseer.close(); + } @Override public ElectionContext copy() { diff --git a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java index aa8943d68b1..46f3c88977b 100644 --- a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java +++ b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java @@ -388,6 +388,7 @@ public class LeaderElector { } if (watcher != null) watcher.cancel(); this.context.cancelElection(); + this.context.close(); this.context = ctx; joinElection(ctx, true, joinAtHead); } 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 89a88e38e46..c0837365bd5 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -75,6 +75,7 @@ import org.apache.solr.common.cloud.ZooKeeperException; import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.util.IOUtils; import org.apache.solr.common.util.ObjectReleaseTracker; import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.URLUtil; @@ -324,6 +325,7 @@ public class ZkController { ElectionContext prevContext = overseerElector.getContext(); if (prevContext != null) { prevContext.cancelElection(); + prevContext.close(); } overseerElector.setup(context); @@ -534,11 +536,8 @@ public class ZkController { } } finally { try { - try { - overseer.close(); - } catch (Exception e) { - log.error("Error closing overseer", e); - } + IOUtils.closeQuietly(overseerElector.getContext()); + IOUtils.closeQuietly(overseer); } finally { try { try {