RE: Deadlocking in the transport
"Lubashev, Igor" <ilubashe@akamai.com> Fri, 12 January 2018 01:28 UTC
Return-Path: <ilubashe@akamai.com>
X-Original-To: quic@ietfa.amsl.com
Delivered-To: quic@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4959812D574 for <quic@ietfa.amsl.com>; Thu, 11 Jan 2018 17:28:37 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=akamai.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4EaUzH5f7gHx for <quic@ietfa.amsl.com>; Thu, 11 Jan 2018 17:28:33 -0800 (PST)
Received: from mx0a-00190b01.pphosted.com (mx0a-00190b01.pphosted.com [IPv6:2620:100:9001:583::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 8F281126BF0 for <quic@ietf.org>; Thu, 11 Jan 2018 17:28:33 -0800 (PST)
Received: from pps.filterd (m0050095.ppops.net [127.0.0.1]) by mx0a-00190b01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0C1Ri1Q027121; Fri, 12 Jan 2018 01:28:29 GMT
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=jan2016.eng; bh=Has/VyL5GOyk5QcR6MxVyEYAw/EseCcj8VU5VECtt2Y=; b=KBaLZNkRZM33x9/xZL5Dv0BU2hp1dJMsUymB4hW+MkkeIo/dMuqT9ICZyMFXL5gfo4/h qKnFVmsmKMaorF72hhol2Y5zs+E54dksZItR+du2jPpxvOmmsAjGSvmVDsPnQK/xAMUV +wLZ5sHzsL+NXwJwMaz16F8mb1xu/SLD5/+vESLQGKucZ8LT/hV0CUJiuktH6RNhTyBV VWgC5JY84SJjK3epDLAJQ9jxerHbx/vsinAAP+4mAaAc2QhHivOYwA5JgxGdUj7xUBsH GlCqQISqSIQzVayZVGWIBBs3CAaMOIflN9uKuKgcxImEM8Ci9MmRTomKbbsay7km9ye9 sQ==
Received: from prod-mail-ppoint1 (prod-mail-ppoint1.akamai.com [184.51.33.18]) by m0050095.ppops.net-00190b01. with ESMTP id 2fda9fhr00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Jan 2018 01:28:28 +0000
Received: from pps.filterd (prod-mail-ppoint1.akamai.com [127.0.0.1]) by prod-mail-ppoint1.akamai.com (8.16.0.21/8.16.0.21) with SMTP id w0C1PqpF013109; Thu, 11 Jan 2018 20:28:27 -0500
Received: from email.msg.corp.akamai.com ([172.27.123.30]) by prod-mail-ppoint1.akamai.com with ESMTP id 2fatnyrt0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2018 20:28:26 -0500
Received: from USMA1EX-DAG1MB5.msg.corp.akamai.com (172.27.123.105) by usma1ex-dag3mb3.msg.corp.akamai.com (172.27.123.58) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 11 Jan 2018 20:28:26 -0500
Received: from USMA1EX-DAG1MB5.msg.corp.akamai.com (172.27.123.105) by usma1ex-dag1mb5.msg.corp.akamai.com (172.27.123.105) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 11 Jan 2018 20:28:25 -0500
Received: from USMA1EX-DAG1MB5.msg.corp.akamai.com ([172.27.123.105]) by usma1ex-dag1mb5.msg.corp.akamai.com ([172.27.123.105]) with mapi id 15.00.1263.000; Thu, 11 Jan 2018 20:28:25 -0500
From: "Lubashev, Igor" <ilubashe@akamai.com>
To: Roberto Peon <fenix@fb.com>, Jana Iyengar <jri@google.com>
CC: QUIC WG <quic@ietf.org>, Martin Thomson <martin.thomson@gmail.com>
Subject: RE: Deadlocking in the transport
Thread-Topic: Deadlocking in the transport
Thread-Index: AQHTidqwSZojuevrjEKuWaFfJc7FkKNt4tSAgAHcoQCAAALNgP//rUOw
Date: Fri, 12 Jan 2018 01:28:25 +0000
Message-ID: <a891c4d345e446e3b172c7a9d7e815b3@usma1ex-dag1mb5.msg.corp.akamai.com>
References: <CABkgnnUSMYRvYNUwzuJk4TQ28qb-sEHmgXhxpjKOBON43_rWCg@mail.gmail.com> <E55BA3F8-39ED-404D-9165-C5E68362206E@fb.com> <CAGD1bZa5H0jf1NqwoA7d0-TREXNdRECeT3BJtgW0rN3Vt-04GA@mail.gmail.com> <18061ACE-08F7-4219-81E6-0B73BBC56170@fb.com>
In-Reply-To: <18061ACE-08F7-4219-81E6-0B73BBC56170@fb.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [172.19.34.88]
Content-Type: multipart/alternative; boundary="_000_a891c4d345e446e3b172c7a9d7e815b3usma1exdag1mb5msgcorpak_"
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_09:, , signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801120015
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-11_09:, , signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801120015
Archived-At: <https://mailarchive.ietf.org/arch/msg/quic/yaZr_Ff-LTol-IMTVhpBv18I0Ko>
X-BeenThere: quic@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Main mailing list of the IETF QUIC working group <quic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/quic>, <mailto:quic-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/quic/>
List-Post: <mailto:quic@ietf.org>
List-Help: <mailto:quic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/quic>, <mailto:quic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 12 Jan 2018 01:28:37 -0000
Transport cannot solve the problem of deadlocking due to a higher protocol’s data priority on its own. The application would need to cooperate carefully. The problem is that it is not only the receiver that is influencing flow control, because sender transport has buffers as well. The sender transport can refuse to accept higher-priority data from the application, if its buffers are already full with lower-priority data. So you can end up with receiver refusing to grant additional credits for stream Y (because it cannot process stream Y w/o stream X). If the sender’s buffers are full of stream Y data, it cannot send that data and cannot accept any additional data (for stream X). The application must be careful not to enqueue stream Y data to the transport before it enqueues all data from stream X that stream Y data depends on. * Igor From: Roberto Peon [mailto:fenix@fb.com] Sent: Thursday, January 11, 2018 8:03 PM To: Jana Iyengar <jri@google.com> Cc: QUIC WG <quic@ietf.org>; Martin Thomson <martin.thomson@gmail.com> Subject: Re: Deadlocking in the transport The receiver would be the one to provide the override; The sender could hint to the receiver that it should wish this by signaling it is blocked (or deadlocked) on flow control. -=R From: Jana Iyengar <jri@google.com<mailto:jri@google.com>> Date: Thursday, January 11, 2018 at 4:53 PM To: Roberto Peon <fenix@fb.com<mailto:fenix@fb.com>> Cc: Martin Thomson <martin.thomson@gmail.com<mailto:martin.thomson@gmail.com>>, QUIC WG <quic@ietf.org<mailto:quic@ietf.org>> Subject: Re: Deadlocking in the transport Roberto, I'm not convinced that we need something as heavy-weight as this... specifically, flow control so far has been in the receiver's control, which is also the thing that owns the resource it is trying to limit exhaustion of. This moves it out to the sender, which would require a receiver to now commit memory based on what a sender believes is important. Reasoning about this seems non-trivial. I worry about how all this degree of freedom will get abused, and potential sharp edges. If we can ensure priority consumption of the shared resource, that seems adequate to resolve the problem on hand. Do you think something more is required? - jana On Wed, Jan 10, 2018 at 12:26 PM, Roberto Peon <fenix@fb.com<mailto:fenix@fb.com>> wrote: Another option: Allow a flow-control ‘override’ which allows a receiver to state that they really want data on a particular stream, and ignore the global flow control for this. How you’d do it: A receiver can send a flow-control override for a stream. This includes the stream id to which the global window temporarily does not apply, the receiver’s current stream flow-control offset, and the offset the receiver would wish to be able to receive. A receiver must continue to (re)send the override (i.e. rexmit) until it is ack’d. It cannot send other flow-control for that stream until the override is ack’d. Thus: global-flow-control-override: <stream-id> <current-flow-control-offset>, <override-flow-control-offset> The sender (which receives the override) credits the global flow control with the difference between the data sent beyond the receivers currently-known flow-control offset upon receipt of the override. This synchronizes the global state between the receiver and the sender. The sender can then send the data on the stream (without touching any other flow control data). Why: This allows for a receiver to resolve priority inversions which would otherwise lead to deadlock, even when the data/dep leading to this was not known to the transport. This extends beyond such issues beyond just header compression. Since the global flow-control exists to protect the app from resource exhaustion, this poses no additional risk to the application. Simply increasing the global flow control provides less strong guarantees—any stream might consume it, which doesn’t resolve the dep inversion. Rejiggering priorities can help to resolve this, but would require the sender to send priorities to the client, which is problematic w.r.t.races and just a web of ick. Having a custom frame type is also a less strong guarantee as it requires the knowledge that the dep exists to be present at the time of sending, which is often impossible. -=R On 1/9/18, 10:17 PM, "QUIC on behalf of Martin Thomson" <quic-bounces@ietf.org<mailto:quic-bounces@ietf.org> on behalf of martin.thomson@gmail.com<mailto:martin.thomson@gmail.com>> wrote: Building a complex application protocol on top of QUIC continues to produce surprises. Today in the header compression design team meeting we discussed a deadlocking issue that I think warrants sharing with the larger group. This has implications for how people build a QUIC transport layer. It might need changes to the API that is exposed by that layer. This isn't really that new, but I don't think we've properly addressed the problem. ## The Basic Problem If a protocol creates a dependency between streams, there is a potential for flow control to deadlock. Say that I send X on stream 3 and Y on stream 7. Processing Y requires that X is processed first. X cannot be sent due to flow control but Y is sent. This is always possible even if X is appropriately prioritized. The receiver then leaves Y in its receive buffer until X is received. The receiver cannot give flow control credit for consuming Y because it can't consume Y until X is sent. But the sender needs flow control credit to send X. We are deadlocked. It doesn't matter whether the stream or connection flow control is causing the problem, either produces the same result. (To give some background on this, we were considering a preface to header blocks that identified the header table state that was necessary to process the header block. This would allow for concurrent population of the header table and sending message that depended on the header table state that is under construction. A receiver would read the identifier and then leave the remainder of the header block in the receive buffer until the header table was ready.) ## Options It seems like there are a few decent options for managing this. These are what occurred to me (there are almost certainly more options): 1. Don't do that. We might concede in this case that seeking the incremental improvement to compression efficiency isn't worth the risk. That is, we might make a general statement that this sort of inter-stream blocking is a bad idea. 2. Force receivers to consume data or reset streams in the case of unfulfilled dependencies. The former seems like it might be too much like magical thinking, in the sense that it requires that receivers conjure more memory up, but if the receiver were required to read Y and release the flow control credit, then all would be fine. For instance, we could require that the receiver reset a stream if it couldn't read and handle data. It seems like a bad arrangement though: you either have to allocate more memory than you would like or suffer the time and opportunity cost of having to do Y over. 3. Create an exception for flow control. This is what Google QUIC does for its headers stream. Roberto observed that we could alternatively create a frame type that was excluded from flow control. If this were used for data that had dependencies, then it would be impossible to deadlock. It would be similarly difficult to account for memory allocation, though if it were possible to process on receipt, then this *might* work. We'd have to do something to address out-of-order delivery though. It's possible that the stream abstraction is not appropriate in this case. 4. Block the problem at the source. It was suggested that in cases where there is a potential dependency, then it can't be a problem if the transport refused to accept data that it didn't have flow control credit for. Writes to the transport would consume flow control credit immediately. That way applications would only be able to write X if there was a chance that it would be delivered. Applications that have ordering requirements can ensure that Y is written after X is accepted by the transport and thereby avoid the deadlock. Writes might block rather than fail, if the API wasn't into the whole non-blocking I/O thing. The transport might still have to buffer X for other reasons, like congestion control, but it can guarantee that flow control isn't going to block delivery. ## My Preference Right now, I'm inclined toward option 4. Option 1 seems a little too much of a constraint. Protocols create this sort of inter-dependency naturally. There's a certain purity in having the flow control exert back pressure all the way to the next layer up. Not being able to build a transport with unconstrained writes is potentially creating undesirable externalities on transport users. Now they have to worry about flow control as well. Personally, I'm inclined to say that this is something that application protocols and their users should be exposed to. We've seen with the JS streams API that it's valuable to have back pressure available at the application layer and also how it is possible to do that relatively elegantly. I'm almost certain that I haven't thought about all the potential alternatives. I wonder if there isn't some experience with this problem in SCTP that might lend some insights.
- Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Brian Trammell (IETF)
- Re: Deadlocking in the transport Willy Tarreau
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Subodh Iyengar
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Ian Swett
- Re: Deadlocking in the transport Mikkel Fahnøe Jørgensen
- Re: Deadlocking in the transport Mikkel Fahnøe Jørgensen
- Re: Deadlocking in the transport Charles 'Buck' Krasic
- Re: Deadlocking in the transport Ted Hardie
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Roberto Peon
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Mikkel Fahnøe Jørgensen
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Christian Huitema
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Jana Iyengar
- RE: Deadlocking in the transport Mike Bishop
- Re: Deadlocking in the transport Mikkel Fahnøe Jørgensen
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Mikkel Fahnøe Jørgensen
- Re: Deadlocking in the transport Martin Thomson
- RE: Deadlocking in the transport Lubashev, Igor
- Re: Deadlocking in the transport Dmitri Tikhonov
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Roberto Peon
- RE: Deadlocking in the transport Lubashev, Igor
- Re: Deadlocking in the transport Mirja Kühlewind
- Re: Deadlocking in the transport Roberto Peon
- Re: Deadlocking in the transport Roberto Peon
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Jana Iyengar
- Re: Deadlocking in the transport Ian Swett
- Re: Deadlocking in the transport Martin Thomson
- Re: Deadlocking in the transport Mirja Kühlewind
- Re: Deadlocking in the transport Charles 'Buck' Krasic
- Re: Deadlocking in the transport Roberto Peon
- Re: Deadlocking in the transport Martin Thomson