Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 33721200C24 for ; Thu, 19 Jan 2017 01:23:49 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 32078160B43; Thu, 19 Jan 2017 00:23:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 78A1B160B56 for ; Thu, 19 Jan 2017 01:23:48 +0100 (CET) Received: (qmail 21205 invoked by uid 500); 19 Jan 2017 00:23:39 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 18086 invoked by uid 99); 19 Jan 2017 00:23:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2017 00:23:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1F645F403A; Thu, 19 Jan 2017 00:23:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jhung@apache.org To: common-commits@hadoop.apache.org Date: Thu, 19 Jan 2017 00:24:00 -0000 Message-Id: In-Reply-To: <51bb37b19be842bf878fb0e1cba339c3@git.apache.org> References: <51bb37b19be842bf878fb0e1cba339c3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [25/30] hadoop git commit: HDFS-10733. NameNode terminated after full GC thinking QJM is unresponsive. Contributed by Vinitha Gankidi. archived-at: Thu, 19 Jan 2017 00:23:49 -0000 HDFS-10733. NameNode terminated after full GC thinking QJM is unresponsive. Contributed by Vinitha Gankidi. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8a0fa0f7 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8a0fa0f7 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8a0fa0f7 Branch: refs/heads/YARN-5734 Commit: 8a0fa0f7e88c45a98c6f266d6349cb426dd06495 Parents: 9130af3 Author: Vinitha Reddy Gankidi Authored: Tue Jan 17 17:21:12 2017 -0800 Committer: Konstantin V Shvachko Committed: Wed Jan 18 12:46:32 2017 -0800 ---------------------------------------------------------------------- .../hadoop/hdfs/qjournal/client/QuorumCall.java | 26 +++++++++++++++++++- .../hdfs/qjournal/client/TestQuorumCall.java | 17 +++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8a0fa0f7/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumCall.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumCall.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumCall.java index f15e462..dc32318 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumCall.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/QuorumCall.java @@ -20,8 +20,10 @@ package org.apache.hadoop.hdfs.qjournal.client; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.TimeoutException; +import java.util.concurrent.TimeUnit; import org.apache.hadoop.ipc.RemoteException; +import org.apache.hadoop.util.StopWatch; import org.apache.hadoop.util.Time; import com.google.common.base.Joiner; @@ -58,6 +60,7 @@ class QuorumCall { * fraction of the configured timeout for any call. */ private static final float WAIT_PROGRESS_WARN_THRESHOLD = 0.7f; + private final StopWatch quorumStopWatch = new StopWatch(); static QuorumCall create( Map> calls) { @@ -83,6 +86,16 @@ class QuorumCall { private QuorumCall() { // Only instantiated from factory method above } + + private void restartQuorumStopWatch() { + quorumStopWatch.reset().start(); + } + + private boolean shouldIncreaseQuorumTimeout(long offset, int millis) { + long elapsed = quorumStopWatch.now(TimeUnit.MILLISECONDS); + return elapsed + offset > (millis * WAIT_PROGRESS_INFO_THRESHOLD); + } + /** * Wait for the quorum to achieve a certain number of responses. @@ -110,6 +123,7 @@ class QuorumCall { long nextLogTime = st + (long)(millis * WAIT_PROGRESS_INFO_THRESHOLD); long et = st + millis; while (true) { + restartQuorumStopWatch(); checkAssertionErrors(); if (minResponses > 0 && countResponses() >= minResponses) return; if (minSuccesses > 0 && countSuccesses() >= minSuccesses) return; @@ -139,11 +153,21 @@ class QuorumCall { } long rem = et - now; if (rem <= 0) { - throw new TimeoutException(); + // Increase timeout if a full GC occurred after restarting stopWatch + if (shouldIncreaseQuorumTimeout(0, millis)) { + et = et + millis; + } else { + throw new TimeoutException(); + } } + restartQuorumStopWatch(); rem = Math.min(rem, nextLogTime - now); rem = Math.max(rem, 1); wait(rem); + // Increase timeout if a full GC occurred after restarting stopWatch + if (shouldIncreaseQuorumTimeout(-rem, millis)) { + et = et + millis; + } } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/8a0fa0f7/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumCall.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumCall.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumCall.java index 2295384..506497e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumCall.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/client/TestQuorumCall.java @@ -66,4 +66,21 @@ public class TestQuorumCall { // expected } } + @Test(timeout=10000) + public void testQuorumFailsWithoutResponse() throws Exception { + Map> futures = ImmutableMap.of( + "f1", SettableFuture.create()); + + QuorumCall q = QuorumCall.create(futures); + assertEquals("The number of quorum calls for which a response has been" + + " received should be 0", 0, q.countResponses()); + + try { + q.waitFor(0, 1, 100, 10, "test"); + fail("Didn't time out waiting for more responses than came back"); + } catch (TimeoutException te) { + // expected + } + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org