From issues-return-176218-apmail-flink-issues-archive=flink.apache.org@flink.apache.org Tue Jul 10 08:41:03 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 F16FC1823B for ; Tue, 10 Jul 2018 08:41:03 +0000 (UTC) Received: (qmail 27933 invoked by uid 500); 10 Jul 2018 08:41:03 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 27893 invoked by uid 500); 10 Jul 2018 08:41:03 -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 27884 invoked by uid 99); 10 Jul 2018 08:41:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2018 08:41:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 710CE18035C for ; Tue, 10 Jul 2018 08:41:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 3_f5AuvFndpq for ; Tue, 10 Jul 2018 08:41:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 6F7395F41A for ; Tue, 10 Jul 2018 08:41:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7E0DCE12FC for ; Tue, 10 Jul 2018 08:41:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 198A321EE8 for ; Tue, 10 Jul 2018 08:41:00 +0000 (UTC) Date: Tue, 10 Jul 2018 08:41:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-9755) Exceptions in RemoteInputChannel#notifyBufferAvailable() are not propagated to the responsible thread MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-9755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16538259#comment-16538259 ] ASF GitHub Bot commented on FLINK-9755: --------------------------------------- Github user NicoK commented on a diff in the pull request: https://github.com/apache/flink/pull/6272#discussion_r201260221 --- 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 -- yes, this one is a tricky one: Logically it should be: first adding the floating buffer, then enqueuing the channel. However, `notifyCreditAvailable()` is outside our control and could potentially fail. If it fails, we have two options: 1) revert any change done by `notifyBufferAvailable()` and freeing the buffer so that it can be directly re-used by `LocalBufferPool` 2) keep everything done by `notifyBufferAvailable()` and rely on `setError()` to clean up eventually - this means we should not recycle the buffer if it was already added to the `bufferQueue`. Giving it a second thought, it may indeed be better to go for solution 2 and keep the logical execution as you proposed (infact, now I can't really think of a reason why I did not do that). We should be able to steer the recycling via the `recycleBuffer` as is already done in other cases. > Exceptions in RemoteInputChannel#notifyBufferAvailable() are not propagated to the responsible thread > ----------------------------------------------------------------------------------------------------- > > Key: FLINK-9755 > URL: https://issues.apache.org/jira/browse/FLINK-9755 > Project: Flink > Issue Type: Bug > Components: Network > Affects Versions: 1.5.0 > Reporter: Nico Kruber > Assignee: Nico Kruber > Priority: Critical > Labels: pull-request-available > Fix For: 1.5.2, 1.6.0 > > > The credit-based flow control implementation of RemoteInputChannel#notifyBufferAvailable() does not forward errors (like the {{IllegalStateException}}) to the thread that is being notified. The calling code at {{LocalBufferPool#recycle}}, however, relies on the callback forwarding errors and completely ignores any failures. > Therefore, we could end up with a program waiting forever for the callback and not even a failure message in the logs. -- This message was sent by Atlassian JIRA (v7.6.3#76005)