From issues-return-176250-apmail-flink-issues-archive=flink.apache.org@flink.apache.org Tue Jul 10 10:26:29 2018 Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D5D6318639 for ; Tue, 10 Jul 2018 10:26:29 +0000 (UTC) Received: (qmail 15133 invoked by uid 500); 10 Jul 2018 10:26:29 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 15092 invoked by uid 500); 10 Jul 2018 10:26:29 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 15083 invoked by uid 99); 10 Jul 2018 10:26:29 -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 Jul 2018 10:26:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 95D6ADFB34; Tue, 10 Jul 2018 10:26:29 +0000 (UTC) From: zhijiangW To: issues@flink.apache.org Reply-To: issues@flink.apache.org References: In-Reply-To: Subject: [GitHub] flink pull request #6272: [FLINK-9755][network] forward exceptions in Remote... Content-Type: text/plain Message-Id: <20180710102629.95D6ADFB34@git1-us-west.apache.org> Date: Tue, 10 Jul 2018 10:26:29 +0000 (UTC) Github user zhijiangW commented on a diff in the pull request: https://github.com/apache/flink/pull/6272#discussion_r201292263 --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/consumer/RemoteInputChannel.java --- @@ -360,32 +360,45 @@ public boolean notifyBufferAvailable(Buffer buffer) { return false; } - boolean needMoreBuffers = false; - synchronized (bufferQueue) { - checkState(isWaitingForFloatingBuffers, "This channel should be waiting for floating buffers."); + boolean recycleBuffer = true; + try { + boolean needMoreBuffers = false; + synchronized (bufferQueue) { + checkState(isWaitingForFloatingBuffers, + "This channel should be waiting for floating buffers."); + + // Important: double check the isReleased state inside synchronized block, so there is no + // race condition when notifyBufferAvailable and releaseAllResources running in parallel. + if (isReleased.get() || + bufferQueue.getAvailableBufferSize() >= numRequiredBuffers) { + isWaitingForFloatingBuffers = false; + buffer.recycleBuffer(); + return false; + } - // Important: double check the isReleased state inside synchronized block, so there is no - // race condition when notifyBufferAvailable and releaseAllResources running in parallel. - if (isReleased.get() || bufferQueue.getAvailableBufferSize() >= numRequiredBuffers) { - isWaitingForFloatingBuffers = false; - buffer.recycleBuffer(); - return false; - } + // note: this call may fail, for better cleanup, increase the counter first + if (unannouncedCredit.getAndAdd(1) == 0) { + notifyCreditAvailable(); --- End diff -- 👍 ---