You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2017/10/02 21:37:11 UTC

AMQP spec question: aborted messages and credit.

Trying to interpret the AMQP spec regarding credit and aborted mesages.

http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-flow-control
says this: "The *delivery-count* is initialized by the sender when a link
endpoint is created, and is incremented whenever a message is *sent*. Only
the sender MAY independently modify this field. The receiver's value is
calculated based on the last known value from the sender and any subsequent
messages *received* on the link." It goes on to say how credit is computed
from delivery count.

My question: for a multi-frame message do *sent* and *received* refer to
the first or last frame of the message? The distinction matters if a
message is aborted:

FIRST: aborted messages are counted in the delivery count, and they do
consume a credit. The receiver of an aborted message must discard the
message, but must account for the delivery in link state exactly as if it
had been completed. In particular the receiver must send a credit for the
aborted message to keep messages flowing. The sender accounts for the
aborted message as for a completed message.

LAST: aborted messages are treated as if they never existed. They aren't
counted by delivery count, they don't consume credit. The receiver of an
abort frame should throw the delivery away and leave link state as it was
before the message started to arrive. The sender of an aborted message
should have link state as if the message had never been sent.

I prefer LAST because I like the clarity of this sentence: "as far as
possible, an aborted message is treated as if it never existed". However I
can't find anything else in the spec to decide either way.

Sadly, proton does the accounting LAST on the sender but FIRST on the
receiver, so that doesn't help. The receiver has a comment:   // XXX: multi
transfer. Sigh.

Cheers,
Alan.

Re: AMQP spec question: aborted messages and credit.

Posted by Alan Conway <ac...@redhat.com>.
I've implemented the approach recommended by Rob in proton, after
discussion with others and based on the implementation I think it makes the
most sense  in terms of implementation effort and risks of interop
problems. It would be good to put in a clarification request for the spec,
Rob I guess you know how to do that, give me a shout off list if you want
me to help.

PROTON-1512: aborted messages: handle credit and empty messages.

The AMQP spec says: "The delivery-count is initialized by the sender when a
link
endpoint is created, and is incremented whenever a message is sent."
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#doc-flow-control

We interpret this to mean when the *first* frame of a message is
sent/received,
so if any frames of an aborted message are sent, it consumes a credit and
increases the delivery count exactly like a successful message.

However: if a proton sender calls pn_delivery_abort() *before* any frames
have
been sent, the delivery is dropped locally, no frames sent, no link-state
updates. This means pn_delivery_abort() will either cancel a local,
partially-constructed message with no side effects, or send an aborted=true
frame as required. Proton will never send a message consisting of a single
aborted frame.

A proton receiver will handle a message consisting of a single aborted frame
correctly - i.e. do credit calculations but consider the delivery aborted.


On Tue, Oct 3, 2017 at 10:02 AM, Alan Conway <ac...@redhat.com> wrote:

>
> On Mon, Oct 2, 2017 at 6:01 PM, Rob Godfrey <ro...@gmail.com>
> wrote:
>
>> On 2 October 2017 at 23:37, Alan Conway <ac...@redhat.com> wrote:
>>
>> > Trying to interpret the AMQP spec regarding credit and aborted mesages.
>> >
>> > http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-
>> > transport-v1.0-os.html#doc-flow-control
>> > says this: "The *delivery-count* is initialized by the sender when a
>> link
>> > endpoint is created, and is incremented whenever a message is *sent*.
>> Only
>> > the sender MAY independently modify this field. The receiver's value is
>> > calculated based on the last known value from the sender and any
>> subsequent
>> > messages *received* on the link." It goes on to say how credit is
>> computed
>> > from delivery count.
>> >
>> > My question: for a multi-frame message do *sent* and *received* refer to
>> > the first or last frame of the message? The distinction matters if a
>> > message is aborted:
>> >
>>
>> I was having this discussion with Robbie over IRC not long ago - we should
>> probably raise a spec clarification JIRA over at OASIS.
>>
>>
>> >
>> > FIRST: aborted messages are counted in the delivery count, and they do
>> > consume a credit. The receiver of an aborted message must discard the
>> > message, but must account for the delivery in link state exactly as if
>> it
>> > had been completed. In particular the receiver must send a credit for
>> the
>> > aborted message to keep messages flowing. The sender accounts for the
>> > aborted message as for a completed message.
>> >
>> > LAST: aborted messages are treated as if they never existed. They aren't
>> > counted by delivery count, they don't consume credit. The receiver of an
>> > abort frame should throw the delivery away and leave link state as it
>> was
>> > before the message started to arrive. The sender of an aborted message
>> > should have link state as if the message had never been sent.
>> >
>> > I prefer LAST because I like the clarity of this sentence: "as far as
>> > possible, an aborted message is treated as if it never existed".
>> However I
>> > can't find anything else in the spec to decide either way.
>> >
>> > Sadly, proton does the accounting LAST on the sender but FIRST on the
>> > receiver, so that doesn't help. The receiver has a comment:   // XXX:
>> multi
>> > transfer. Sigh.
>> >
>> >
>> So - I think the "correct" answer should be FIRST for both sender and
>> receiver.  Consider the following case:
>>
>> A sender starts sending a very large message to a receiver.  The receiver
>> parses the message as it arrives, and once it has seen the headers it
>> knows
>> (without processing the rest of the message) that it wants to reject this
>> message.  The receiver sends the REJECT disposition and settles the
>> transfer.  At this point the sender of the message knows that it is
>> pointless to send any more of the message so it can abort.
>>
>> In credit accounting terms there is no reason why this case should be
>> treated differently than if the receiver didn't reject before it received
>> the whole of the message, or if the sender decided to carry on sending the
>> message even though it knows that the receiver has metaphorically stuck
>> its
>> fingers in its ears and is going "nah nah nah can't hear you".
>>
>>
> It's a good argument, damn you. A receiver-initiated abort, trust your
> contorted mind to come up with such a thing.
> After a reject/settle most implementations probably won't even pay
> attention to the belated abort. Plus we know at least proton does the
> accounting on the first frame on the receiver, so from a backwards-compat
> interop point of view it does seem like a safer option.
>
> If we do that, then someone has to send additional credit for the aborted
> message. Should it be done automatically by proton or left to the app? If I
> was designing from scratch I'd say the app, proton never issues credit
> without being told in any other circumstance. But the backwards-compat
> problem would argue for doing it in proton automatically.
>

Re: AMQP spec question: aborted messages and credit.

Posted by Alan Conway <ac...@redhat.com>.
On Mon, Oct 2, 2017 at 6:01 PM, Rob Godfrey <ro...@gmail.com> wrote:

> On 2 October 2017 at 23:37, Alan Conway <ac...@redhat.com> wrote:
>
> > Trying to interpret the AMQP spec regarding credit and aborted mesages.
> >
> > http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-
> > transport-v1.0-os.html#doc-flow-control
> > says this: "The *delivery-count* is initialized by the sender when a link
> > endpoint is created, and is incremented whenever a message is *sent*.
> Only
> > the sender MAY independently modify this field. The receiver's value is
> > calculated based on the last known value from the sender and any
> subsequent
> > messages *received* on the link." It goes on to say how credit is
> computed
> > from delivery count.
> >
> > My question: for a multi-frame message do *sent* and *received* refer to
> > the first or last frame of the message? The distinction matters if a
> > message is aborted:
> >
>
> I was having this discussion with Robbie over IRC not long ago - we should
> probably raise a spec clarification JIRA over at OASIS.
>
>
> >
> > FIRST: aborted messages are counted in the delivery count, and they do
> > consume a credit. The receiver of an aborted message must discard the
> > message, but must account for the delivery in link state exactly as if it
> > had been completed. In particular the receiver must send a credit for the
> > aborted message to keep messages flowing. The sender accounts for the
> > aborted message as for a completed message.
> >
> > LAST: aborted messages are treated as if they never existed. They aren't
> > counted by delivery count, they don't consume credit. The receiver of an
> > abort frame should throw the delivery away and leave link state as it was
> > before the message started to arrive. The sender of an aborted message
> > should have link state as if the message had never been sent.
> >
> > I prefer LAST because I like the clarity of this sentence: "as far as
> > possible, an aborted message is treated as if it never existed". However
> I
> > can't find anything else in the spec to decide either way.
> >
> > Sadly, proton does the accounting LAST on the sender but FIRST on the
> > receiver, so that doesn't help. The receiver has a comment:   // XXX:
> multi
> > transfer. Sigh.
> >
> >
> So - I think the "correct" answer should be FIRST for both sender and
> receiver.  Consider the following case:
>
> A sender starts sending a very large message to a receiver.  The receiver
> parses the message as it arrives, and once it has seen the headers it knows
> (without processing the rest of the message) that it wants to reject this
> message.  The receiver sends the REJECT disposition and settles the
> transfer.  At this point the sender of the message knows that it is
> pointless to send any more of the message so it can abort.
>
> In credit accounting terms there is no reason why this case should be
> treated differently than if the receiver didn't reject before it received
> the whole of the message, or if the sender decided to carry on sending the
> message even though it knows that the receiver has metaphorically stuck its
> fingers in its ears and is going "nah nah nah can't hear you".
>
>
It's a good argument, damn you. A receiver-initiated abort, trust your
contorted mind to come up with such a thing.
After a reject/settle most implementations probably won't even pay
attention to the belated abort. Plus we know at least proton does the
accounting on the first frame on the receiver, so from a backwards-compat
interop point of view it does seem like a safer option.

If we do that, then someone has to send additional credit for the aborted
message. Should it be done automatically by proton or left to the app? If I
was designing from scratch I'd say the app, proton never issues credit
without being told in any other circumstance. But the backwards-compat
problem would argue for doing it in proton automatically.

Re: AMQP spec question: aborted messages and credit.

Posted by Rob Godfrey <ro...@gmail.com>.
On 2 October 2017 at 23:37, Alan Conway <ac...@redhat.com> wrote:

> Trying to interpret the AMQP spec regarding credit and aborted mesages.
>
> http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-
> transport-v1.0-os.html#doc-flow-control
> says this: "The *delivery-count* is initialized by the sender when a link
> endpoint is created, and is incremented whenever a message is *sent*. Only
> the sender MAY independently modify this field. The receiver's value is
> calculated based on the last known value from the sender and any subsequent
> messages *received* on the link." It goes on to say how credit is computed
> from delivery count.
>
> My question: for a multi-frame message do *sent* and *received* refer to
> the first or last frame of the message? The distinction matters if a
> message is aborted:
>

I was having this discussion with Robbie over IRC not long ago - we should
probably raise a spec clarification JIRA over at OASIS.


>
> FIRST: aborted messages are counted in the delivery count, and they do
> consume a credit. The receiver of an aborted message must discard the
> message, but must account for the delivery in link state exactly as if it
> had been completed. In particular the receiver must send a credit for the
> aborted message to keep messages flowing. The sender accounts for the
> aborted message as for a completed message.
>
> LAST: aborted messages are treated as if they never existed. They aren't
> counted by delivery count, they don't consume credit. The receiver of an
> abort frame should throw the delivery away and leave link state as it was
> before the message started to arrive. The sender of an aborted message
> should have link state as if the message had never been sent.
>
> I prefer LAST because I like the clarity of this sentence: "as far as
> possible, an aborted message is treated as if it never existed". However I
> can't find anything else in the spec to decide either way.
>
> Sadly, proton does the accounting LAST on the sender but FIRST on the
> receiver, so that doesn't help. The receiver has a comment:   // XXX: multi
> transfer. Sigh.
>
>
So - I think the "correct" answer should be FIRST for both sender and
receiver.  Consider the following case:

A sender starts sending a very large message to a receiver.  The receiver
parses the message as it arrives, and once it has seen the headers it knows
(without processing the rest of the message) that it wants to reject this
message.  The receiver sends the REJECT disposition and settles the
transfer.  At this point the sender of the message knows that it is
pointless to send any more of the message so it can abort.

In credit accounting terms there is no reason why this case should be
treated differently than if the receiver didn't reject before it received
the whole of the message, or if the sender decided to carry on sending the
message even though it knows that the receiver has metaphorically stuck its
fingers in its ears and is going "nah nah nah can't hear you".

-- Rob


> Cheers,
> Alan.
>