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 75933200C2B for ; Thu, 2 Mar 2017 16:37:43 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 73D82160B6F; Thu, 2 Mar 2017 15:37:43 +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 6E8BF160B61 for ; Thu, 2 Mar 2017 16:37:42 +0100 (CET) Received: (qmail 49984 invoked by uid 500); 2 Mar 2017 15:37:41 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 49967 invoked by uid 99); 2 Mar 2017 15:37:41 -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; Thu, 02 Mar 2017 15:37:41 +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 BA831180031 for ; Thu, 2 Mar 2017 15:37:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.18 X-Spam-Level: * X-Spam-Status: No, score=1.18 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com 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 lJsYSVGNAT-3 for ; Thu, 2 Mar 2017 15:37:38 +0000 (UTC) Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id F024C5F23D for ; Thu, 2 Mar 2017 15:37:37 +0000 (UTC) Received: by mail-qk0-f178.google.com with SMTP id s186so129096145qkb.1 for ; Thu, 02 Mar 2017 07:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NxYlMC+UIYt9ZSm8/RviiMotcx3yzshkjIPQPnzsguo=; b=IRRXBeiKOiKi4g2CuHuKfikM4crFnPJV43aM1cadODJKGcm5Nd2WkYSWZmvRpAS8Pm tAckLofrHwNA++cIJjpnLjb+4NoR4PIc0HZzaqqYhrb7WUOZvZeTmHLPXzISJ8Tzb6kW EvCJ2F5ZFLIryqYmGbB0ayN5O+MNSggNTg6VfFIfmhp0Hc8mMBObG/34UIiyu7pfi1tw mUkNirga3Y7NyA7MgBgpHg94VaBMk0nj4Mi25f2ufFUXc9N73MoDPSGVE7Vkhb8JbMJT HgUwRFdLuWURwvxFPPRT9NgQ9T44D+S/jMyIxqcR53oyPs+In5Q5Fza9ICcfPjQ80oFT HR0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NxYlMC+UIYt9ZSm8/RviiMotcx3yzshkjIPQPnzsguo=; b=IwBw75acOStJRX+KsrcTid7A4DRqQqv4HwHQEk5PNt9FW3ZYbxhYtI3pkuLJLkQKt7 JMMX1+q2GH60VFiYQaluZUNB1zLtDsVzPTW3qf2jgX5q+u20WDWRR+cZxosoWrJ1O4zJ wTJdYjLtA0C5c56p2/3e++dLAT3mMMjbJ3bQgiPHuFBojn1kB2ci3fGI0mIhqHCe8Re8 vQnlaZnl4BpqlOiH7ANV/ple31lPFylnfoHAAS8tgOugVOaJe1GPnoIRAcqoe9xIpjKD D56AaLs+OoP5V5CRy+e7Rwjin2F7SZo6GtHpgm7osBtMafsFACnLraT/IQsX66dWsbBL +NVQ== X-Gm-Message-State: AMke39l7yuJaWsbFUdFiUJVsg1eUjd0A0D7QrWCVJ0OAXBbz782RmNfUF1Ro1xiQRjQHpujwj9C0PKgO+IdgEQ== X-Received: by 10.237.60.3 with SMTP id t3mr19299900qte.86.1488469053395; Thu, 02 Mar 2017 07:37:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.45.100 with HTTP; Thu, 2 Mar 2017 07:37:32 -0800 (PST) In-Reply-To: References: <1488378679.5694.23.camel@gmail.com> <2c42870f-fb03-e26a-f046-5caf6e1d1609@redhat.com> <3aaeeef5-0edd-2e7a-83ba-8f33bef87663@redhat.com> From: Robbie Gemmell Date: Thu, 2 Mar 2017 15:37:32 +0000 Message-ID: Subject: Re: [proton-j] handling of link-credit To: "users@qpid.apache.org" Content-Type: text/plain; charset=UTF-8 archived-at: Thu, 02 Mar 2017 15:37:43 -0000 On 2 March 2017 at 13:59, Rob Godfrey wrote: > On 2 March 2017 at 13:34, Robbie Gemmell wrote: > >> On 2 March 2017 at 12:06, Rob Godfrey wrote: >> > On 2 March 2017 at 12:56, Robbie Gemmell >> wrote: >> > >> >> On 1 March 2017 at 18:28, Gordon Sim wrote: >> >> > On 01/03/17 18:14, Rob Godfrey wrote: >> >> >> >> >> >> The link credit is an absolute value on the wire... but proton >> presents >> >> it >> >> >> in relative terms. If you had 500 units of credit outstanding and >> >> >> flow(-500) and then flow(2), and you get 5 messages on the wire >> arriving >> >> >> after that point... what state is your link credit in in Proton? >> >> > >> >> > >> >> > I would expect it to be 0. >> >> > >> >> >> Does it >> >> >> make a difference if those 5 messages had been processed by Proton >> (but >> >> >> not >> >> >> received by the application) before the flow(2) was sent or not? >> >> > >> >> > >> >> > Yes, if the flow(2) was issued after the 5 messages were processed, I >> >> would >> >> > expect the credit to be 2. >> >> > >> >> >> >> I think we need to be clearer what we mean by 'in proton' when >> >> discussing this - at the application level, or the transport/wire >> >> level, and before or after the application processes received >> >> messages, as these are all potentially in different states / >> >> presenting different views/values for credit at a given time. Indeed >> >> doing any of this inside e.g the container/reactor will often give a >> >> different result than it would in e.g the JMS client, since the >> >> effects of operations will actually occur at different times. >> >> >> >> I'm not sure most of them will currently match your expectations, >> >> credit will actually end up negative in a lot of them. Note in your >> >> example, when the timer refreshed credit by doing flow(100) the link >> >> credit on the wire actually went to 74, because 3 messages were >> >> received/buffered and processed at the receiver before it actually >> >> sent the flow reducing credit to 0, then 26 in flight were processed >> >> after, making credit end up at -26 once they were all processed, >> >> giving an effective 74 later when the flow(100) occurred to 'add 100' >> >> credits. >> >> >> >> Ignore proton for a minute and consider the following at a protocol >> >> level. If as a sender you get a flow saying delivery-count is 0 and >> >> credit is 100, and send 50 messages in-flight, then get a flow >> >> indicating delivery-count is 10 and credit is 0, then receive a flow >> >> indicating delivery-count is 20 and credit is 10, what is your actual >> >> credit at the sender and receiver when all is done? >> > >> > >> > >> > So at this point I would say that the sender considers credit to be 0 >> > (there's no point in the sender trying to store a negative link-credit >> > amount), at the receiver the link credit is (the most recent >> delivery-count >> > it saw from the sender) - 30 (this value may be negative). >> > >> >> The spec seems to say it MUST go negative at the sender. From >> http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core- >> transport-v1.0-os.html#doc-flow-control >> on link credit: >> >> "The sender's value MUST always be maintained in such a way as to >> match the delivery-limit identified by the receiver. This means that >> the sender's link-credit variable MUST be set according to this >> formula when flow information is given by the receiver: >> >> link-creditsnd := delivery-countrcv + link-creditrcv - delivery-countsnd. " >> >> So in this case the the receivers last known delivery count was 20, >> and the credit was 10, and the senders delivery count was already 50 >> at that point. This makes the senders credit -20 (not -30 as I >> incorrectly stated below because I cant count, and the sender >> delivery-count was only 20 beyond what it could ever become based on >> the flow). >> >> So the sender sees -20 credit as soon as the flow arrives saying 10, >> and the receiver ends up seeing -20 once it sees(/processes) all the >> messages. >> >> > Theoretically this may be correct, however obviously the credit value on > the wire is a uint, so it can't actually be negative. True, I was meaning the effective/stored/calculated value, not the wire value...much like the spec talks of it being less than zero when as you note it never can be on the wire. > If the receiver has > sent a flow with echo=true then I would expect the sender to respond with a > flow with the accurate delivery count and a link-credit of 0. In the scenario I wasnt meaning for the 0 credit flow to have an echo, since we cant do that currently, and thats why it didnt wait for the sender to hit 0 credit before sending the next flow, in part to show/put it in position where I see issue with how this would currently behave. If it did support echo, I'm not sure it would reply with credit of 0 currently. > Given that > the effect of -ve credit and zero credit would seem to be identical I don't > think it really matters what the sender stores internally ... though using > 0 would allow the library to store the credit value in a uint and not have > to futz with the stored value every time it echoes the flow state on the > wire. I agree. Proton doesn't look to take either approach currently however. > > -- Rob > >> >> >> The receivers last >> >> flow had just said credit is 10, but the senders delivery-count is >> >> already 30 beyond what it could ever become based on that flow, so >> >> credit should actually be -30 at the sender now. The receiver also >> >> doesn't just end up at 0 after getting 10 more messages based on its >> >> last flow, and instead has to cope (or fall over and close the link) >> >> when an additional 20 more messages arrive than it seemingly just gave >> >> credit for; despite having previously reduced credit from 100 to 0 and >> >> increasing it back to 10 after receiving 20 messages, 30 more messages >> >> arrived since it never found out if the reduction to 0 took effect and >> >> it turns out that 50 (or even up to 100) were sent using the original >> >> credit before it adjusted the credit twice more. Suppose we say that >> >> the receiver actually successfully processes all 50 messages despite >> >> that, this makes its delivery-count now 50 as well, what is its >> >> credit? >> >> >> >> >> > I think here there are two separate considerations... On the wire I would >> > think that the receiver should update its delivery count to reflect the >> > last received delivery from the sender (unless it just decides to tear >> down >> > the link), and I would expect that the link-credit at this point would be >> > zero. >> >> That would be fine I think, though it doenst currently do this, and to >> your point below it would be interesting when to if it did. Currently >> at the application level, it doesnt see credit go negative until it >> processes enough messages to make it do so, with unprocessed messages >> being 'queued' and not yet reflected in credit views. The transport >> level does I think consider the credit reduced as soon as they fully >> arrive. >> >> > >> > More interesting to me is how we handle this in the interaction between >> the >> > library and application layers. Does the application layer have to issue >> > more credit before the library presents the deliveries to it (even though >> > the library is already holding the deliveries). If not then does the >> > application layer have to issue retrospective credits in order to start >> > receiving new messages? >> > >> > I'm not sure the accounting part is hard... it's getting the API right >> that >> > seems more tricky to me. >> > >> > -- Rob >> > >> > >> >> >> >> > >> >> > --------------------------------------------------------------------- >> >> > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org >> >> > For additional commands, e-mail: users-help@qpid.apache.org >> >> > >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org >> >> For additional commands, e-mail: users-help@qpid.apache.org >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org >> For additional commands, e-mail: users-help@qpid.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org For additional commands, e-mail: users-help@qpid.apache.org