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 C833D200D16 for ; Tue, 10 Oct 2017 21:50:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C6CAD160BE0; Tue, 10 Oct 2017 19:50:00 +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 1639C1609CB for ; Tue, 10 Oct 2017 21:49:59 +0200 (CEST) Received: (qmail 79362 invoked by uid 500); 10 Oct 2017 19:49:59 -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 79352 invoked by uid 99); 10 Oct 2017 19:49:59 -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; Tue, 10 Oct 2017 19:49:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 167DBF218B; Tue, 10 Oct 2017 19:49:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jlowe@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HADOOP-14912. FairCallQueue may defer servicing calls. Contributed by Daryn Sharp Date: Tue, 10 Oct 2017 19:49:59 +0000 (UTC) archived-at: Tue, 10 Oct 2017 19:50:01 -0000 Repository: hadoop Updated Branches: refs/heads/branch-3.0 61ac7c82f -> c0d56cad5 HADOOP-14912. FairCallQueue may defer servicing calls. Contributed by Daryn Sharp (cherry picked from commit 1123f8f0b62292197f5433cd40e66d8620044608) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c0d56cad Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c0d56cad Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c0d56cad Branch: refs/heads/branch-3.0 Commit: c0d56cad5c7c7345492628b4e24717bea8208ac6 Parents: 61ac7c8 Author: Jason Lowe Authored: Tue Oct 10 14:47:25 2017 -0500 Committer: Jason Lowe Committed: Tue Oct 10 14:49:15 2017 -0500 ---------------------------------------------------------------------- .../src/main/java/org/apache/hadoop/ipc/FairCallQueue.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c0d56cad/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java index 20161b8..6d9ea3e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/FairCallQueue.java @@ -122,13 +122,15 @@ public class FairCallQueue extends AbstractQueue private E removeNextElement() { int priority = multiplexer.getAndAdvanceCurrentIndex(); E e = queues.get(priority).poll(); - if (e == null) { + // a semaphore permit has been acquired, so an element MUST be extracted + // or the semaphore and queued elements will go out of sync. loop to + // avoid race condition if elements are added behind the current position, + // awakening other threads that poll the elements ahead of our position. + while (e == null) { for (int idx = 0; e == null && idx < queues.size(); idx++) { e = queues.get(idx).poll(); } } - // guaranteed to find an element if caller acquired permit. - assert e != null : "consumer didn't acquire semaphore!"; return e; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org