Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F283010F0C for ; Mon, 1 Dec 2014 19:49:04 +0000 (UTC) Received: (qmail 65411 invoked by uid 500); 1 Dec 2014 19:49:04 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 65341 invoked by uid 500); 1 Dec 2014 19:49:04 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 65332 invoked by uid 99); 1 Dec 2014 19:49:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Dec 2014 19:49:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 438A89B428D; Mon, 1 Dec 2014 19:49:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cmccabe@apache.org To: common-commits@hadoop.apache.org Message-Id: <0764a3dc54e84050b0d54800a804218d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HADOOP-11333. Fix deadlock in DomainSocketWatcher when the notification pipe is full (zhaoyunjiong via cmccabe) (cherry picked from commit 86e3993def01223f92b8d1dd35f6c1f8ab6033f5) Date: Mon, 1 Dec 2014 19:49:04 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2 c7bd22974 -> f6d1bf5ed HADOOP-11333. Fix deadlock in DomainSocketWatcher when the notification pipe is full (zhaoyunjiong via cmccabe) (cherry picked from commit 86e3993def01223f92b8d1dd35f6c1f8ab6033f5) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f6d1bf5e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f6d1bf5e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f6d1bf5e Branch: refs/heads/branch-2 Commit: f6d1bf5ed1cf647d82e676df15587de42b1faa42 Parents: c7bd229 Author: Colin Patrick Mccabe Authored: Mon Dec 1 11:42:10 2014 -0800 Committer: Colin Patrick Mccabe Committed: Mon Dec 1 11:48:53 2014 -0800 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../apache/hadoop/net/unix/DomainSocketWatcher.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/f6d1bf5e/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 3facb02..788bf31 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -113,6 +113,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11257. Update "hadoop jar" documentation to warn against using it for launching yarn jars (iwasakims via cmccabe) + HADOOP-11333. Fix deadlock in DomainSocketWatcher when the notification + pipe is full (zhaoyunjiong via cmccabe) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/f6d1bf5e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java index 95ef30d..0172f6b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java @@ -103,6 +103,7 @@ public final class DomainSocketWatcher implements Closeable { public boolean handle(DomainSocket sock) { assert(lock.isHeldByCurrentThread()); try { + kicked = false; if (LOG.isTraceEnabled()) { LOG.trace(this + ": NotificationHandler: doing a read on " + sock.fd); @@ -228,6 +229,14 @@ public final class DomainSocketWatcher implements Closeable { * Whether or not this DomainSocketWatcher is closed. */ private boolean closed = false; + + /** + * True if we have written a byte to the notification socket. We should not + * write anything else to the socket until the notification handler has had a + * chance to run. Otherwise, our thread might block, causing deadlock. + * See HADOOP-11333 for details. + */ + private boolean kicked = false; public DomainSocketWatcher(int interruptCheckPeriodMs) throws IOException { if (loadingFailureReason != null) { @@ -348,8 +357,14 @@ public final class DomainSocketWatcher implements Closeable { */ private void kick() { assert(lock.isHeldByCurrentThread()); + + if (kicked) { + return; + } + try { notificationSockets[0].getOutputStream().write(0); + kicked = true; } catch (IOException e) { if (!closed) { LOG.error(this + ": error writing to notificationSockets[0]", e);