From fd211a5275b6231e668268fb9df2820e07f5f33c Mon Sep 17 00:00:00 2001 From: Mohammad Arshad Date: Thu, 16 Feb 2017 03:34:18 +0530 Subject: [PATCH] ZOOKEEPER-2687: Deadlock while shutting down the Leader server Leader server enters into deadlock while shutting down itself. Shutdown of the leader server is called from the synchronized block which must be called from outside the synchronized block. For detail pls refer ZOOKEEPER-2380 Author: Mohammad Arshad Reviewers: Abraham Fine , Rakesh Radhakrishnan Closes #176 from arshadmohammad/ZOOKEEPER-2687 and squashes the following commits: 7551f5c [Mohammad Arshad] Fixed Rakesh's comments 1e3ed70 [Mohammad Arshad] ZOOKEEPER-2687:Deadlock while shutting down the Leader server. --- src/java/main/org/apache/zookeeper/server/quorum/Leader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java/main/org/apache/zookeeper/server/quorum/Leader.java b/src/java/main/org/apache/zookeeper/server/quorum/Leader.java index 7663d71bb86..0ef5e2c6b0d 100644 --- a/src/java/main/org/apache/zookeeper/server/quorum/Leader.java +++ b/src/java/main/org/apache/zookeeper/server/quorum/Leader.java @@ -590,8 +590,9 @@ void lead() throws IOException, InterruptedException { // check leader running status if (!this.isRunning()) { - shutdown("Unexpected internal error"); - return; + // set shutdown flag + shutdownMessage = "Unexpected internal error"; + break; } if (!tickSkip && !syncedAckSet.hasAllQuorums()) {