Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[azservicebus] Better ReceiveAndDelete behavior when receiving then closing the link #24078

Open
1 of 3 tasks
richardpark-msft opened this issue Feb 10, 2025 · 2 comments
Open
1 of 3 tasks
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Bus

Comments

@richardpark-msft
Copy link
Member

richardpark-msft commented Feb 10, 2025

When doing this pattern, with ReceiveAndDelete links, you can lose messages even if you do everything right:

messages, err := receiver.ReceiveMessages(ctx, n > 1)
// this limbo area is a problem
receiver.Close()

The problem here is if there are any excess credits after ReceiveMessages finishes (for instance, if you ask for 100, but only get 3) then those messages will be cached, and lost when Close() is called.

I think we've got two solutions ahead of us, and I've already rejected one of them, making the rest of this process pretty easy:

  • REJECTED: Allow the user to call into ReceiveMessges and only receive cached messages. This has some precedent, as you can do this in some of the other clients, but you, as a consumer, wouldn't know how many messages are cached and you still have a race condition between messages arriving and Close().
  • CHOSEN: Bring back the 'drain' approach we used, prior to our release callback method. This has the benefit of making sure that every ReceiveMessages() finishes clean - we'll never have any messages in our internal caches and can always make sure the user has everything.

So, we have a few work items for this:

  • Bring back the DrainCredits() function, which has been removed in go-amqp. goamqp PR
  • Add in drain support into Service Bus
  • Update our stress tests to validate that we're not dropping messages in ReceiveAndDelete mode. Probably just take the sample code above, and turn it up to 11.
@richardpark-msft richardpark-msft self-assigned this Feb 10, 2025
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Service Bus labels Feb 10, 2025
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @EldertGrootenboer.

@jhendrixMSFT jhendrixMSFT removed the Service Attention Workflow: This issue is responsible by Azure service team. label Feb 10, 2025
@richardpark-msft
Copy link
Member Author

Status update: DrainCredits has been added, I'm now on the "add and test drain support in Service Bus" portion.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Bus
Projects
None yet
Development

No branches or pull requests

2 participants