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 6704A200C2B for ; Thu, 2 Mar 2017 13:07:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6572B160B6F; Thu, 2 Mar 2017 12:07:06 +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 AF329160B61 for ; Thu, 2 Mar 2017 13:07:05 +0100 (CET) Received: (qmail 48973 invoked by uid 500); 2 Mar 2017 12:07:04 -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 48961 invoked by uid 99); 2 Mar 2017 12:07:04 -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 12:07:04 +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 0DE4B188A04 for ; Thu, 2 Mar 2017 12:07:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.679 X-Spam-Level: * X-Spam-Status: No, score=1.679 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-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 TyktY57H6f79 for ; Thu, 2 Mar 2017 12:07:01 +0000 (UTC) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 2E6325FB62 for ; Thu, 2 Mar 2017 12:07:01 +0000 (UTC) Received: by mail-qk0-f179.google.com with SMTP id n127so119578900qkf.0 for ; Thu, 02 Mar 2017 04:07:01 -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=9+oU/l31iFqzPEZEKjvFuBVll8D1QBB4Ntu6lnxxjD4=; b=C4HECFzzfRAOgLomQVC6SnbE3vhAwRMuL8ofNjHV/L6McrJhbyiN5alsF/+T3pl7y4 ADcRcyHcG/uS8Hz6ote4QmWiZeW4ZFKmtjtm6k6kUFxjZbk98GY0QyZIKQXSWM246MAx 8vV03AOK6KFPVbC3Xj08e7IdSMJS5yPSH0b2qVmy3kTuQ8JUeeC4wlh43UC6n248k9Al v8ZDPKIKFopIBM0YtqCW2MN0wiBw3oZQo54k6fclK+g1PnGilNziD+JKJUPCaQXgglFs Hp0vWsUiHDKj7OKl49egpq0CRnI9EuijvaWfO81LztiAAHgzsy/ahdbYsL9S7bginBiH ZbtA== 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=9+oU/l31iFqzPEZEKjvFuBVll8D1QBB4Ntu6lnxxjD4=; b=NQDU1iAnmHVTtScJ+lcYYQLMBLFmnMwGDcfYNGXYnMeM792vVlU8jA53C1x33usPfN YMJYRZsNki/xjxA7z2w/RYpTOxBuMd7rQbu+qyFkIbCxYIS1AJjNHMsjTyLKpIixoVHx 8rfJd/SVo95y3ExTnmpgvDLcKxrUpTfwCHuFR44OFErLQHYIBlaHAeYWbMBldxz7Qmmx RrdqEmrkqzrWN0C7MH+iRI8I86/ExuwsmBXCVjkDsVBdh9xCmvSedgCpVEtvs4j05u1f 67U+f9XRG+C3FjHqEfEisn8RUjaffEQmkEncI3PmKxLaThb5o8dxtFaOtYalo2oAHcRH JQTA== X-Gm-Message-State: AMke39ln5FauI9Eahb0lYeRa+AzT1J2ZxykrtPC81SwI/L9BoMgGUHJW2mUwbmK4VJWsUIKxbX28jjcWbKgpQQ== X-Received: by 10.55.93.131 with SMTP id r125mr17104496qkb.208.1488456418341; Thu, 02 Mar 2017 04:06:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.137.59 with HTTP; Thu, 2 Mar 2017 04:06:57 -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: Rob Godfrey Date: Thu, 2 Mar 2017 13:06:57 +0100 Message-ID: Subject: Re: [proton-j] handling of link-credit To: "users@qpid.apache.org" Content-Type: multipart/alternative; boundary=001a114e6ace14590d0549be4477 archived-at: Thu, 02 Mar 2017 12:07:06 -0000 --001a114e6ace14590d0549be4477 Content-Type: text/plain; charset=UTF-8 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 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. 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 > > --001a114e6ace14590d0549be4477--