ServiceBusReceiver receive_messages max_wait_time race condition locks the message but sends back empty list #35591
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Messaging
Messaging crew
needs-team-attention
This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Bus
Package Name:
pip install azure-servicebus
Package Version:
7.12.2
Operating System: MacOS and Ubuntu
Python Version: 3.8.18
Describe the bug
Receiving code:
If
max_wait_time
is set inServiceBusReceiver.receive_messages
, then a race condition can happen where a message gets locked by thereceive_message
action butreceive_messages
returns back an empty list, locking this message for the duration of the lockout period.To Reproduce
Steps to reproduce the behavior:
Actual behaviour: some of the messages will get locked in the queue. From our experiments roughly 2-4 messages out of 100 get put into the locked state without them being complete. The receive_messages method shouldn't lock a message unless it can return that message in full.
Expected behavior
All the messages will get completed. No message would get locked out.
I suspect the code for that behaviour is somewhere in here: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/servicebus/azure-servicebus/azure/servicebus/_servicebus_receiver.py#L454
Perhaps it can be configured so that max_time_out can allow a bit of "grace period" to allow the full message to be received and then terminate afterwards once the max_time_out is reached.
The text was updated successfully, but these errors were encountered: