Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Incorrect Handling of AutoCompleteMessages in AzureServiceBus Leads to Invalid Lock Error #1598

Open
yang-xiaodong opened this issue Oct 18, 2024 · 2 comments
Assignees

Comments

@yang-xiaodong
Copy link
Member

Hi @mviegas

I received a subscription sponsorship for Azure ASB from Microsoft. Today, while testing Azure Service Bus, I encountered a "The lock supplied is invalid" error. I searched for the same issue on StackOverflow: https://stackoverflow.com/questions/28127001/the-lock-supplied-is-invalid-either-the-lock-expired-or-the-message-has-alread. The answer pointed towards the AutoCompleteMessages setting.

I checked the definition of AutoCompleteMessages.

It seems there's a logic error when acknowledging messages.

if (_serviceBusProcessor?.AutoCompleteMessages ?? false)
    commitInput.CompleteMessageAsync().GetAwaiter().GetResult();

See

if (_serviceBusProcessor?.AutoCompleteMessages ?? false)
commitInput.CompleteMessageAsync().GetAwaiter().GetResult();

I believe the correct behavior should be to manually call CompleteMessageAsync when AutoComplete is disabled. So, I think this line should be modified to if (!_serviceBusProcessor!.AutoCompleteMessages).

Additionally, the default value of the AutoCompleteMessages property in AzureServiceBusOptions should be set to false. It was changed to true in a previous commit.

What do you think about this and am I missing something?

@scrapstation
Copy link

Can we speed up the release of this change? The latest version cannot use AzureServiceBus.

@yang-xiaodong
Copy link
Member Author

@scrapstation Try to use version 8.3.2-preview-248100009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants