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

ServiceBusReceiver.peek_messages when receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE, consumes 1 message. #31712

Closed
lubomirmatus opened this issue Aug 18, 2023 · 11 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. 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 Service Bus

Comments

@lubomirmatus
Copy link

  • Package Name: azure-servicebus
  • Package Version: 7.11.1 (in 7.8.2 was OK)
  • Operating System: Windows 10 x64
  • Python Version: 3.11.1

Describe the bug
ServiceBusReceiver with receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE method peek_messages consumes 1 message from topic/subscription. When receive_mode=ServiceBusReceiveMode.PEEK_LOCK then method peek_messages is working OK.
This behavior was spotted in azure-servicebus 7.1.11, for example older version 7.8.2 was OK.

To Reproduce
client = ServiceBusClient.from_connection_string(conn_str='my_connection', logging_enable=False)
receiver = client.get_subscription_receiver(topic_name='my_topic', subscription_name='my_subscription', receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE, keep_alive=0, prefetch_count=0)
messages = receiver.peek_messages(max_message_count=1000, timeout=10) # Peeks messages and consumes 1st message from topic.

Expected behavior
The method peek_messages should not modify topic and consume/delete messages.

@github-actions github-actions bot added 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. needs-team-triage This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus labels Aug 18, 2023
@kashifkhan kashifkhan added the Messaging Messaging crew label Aug 18, 2023
@kashifkhan
Copy link
Member

@lubomirmatus Im trying to reproduce this and I wanted to clarify a few things. Assuming my topic/subscription has 100 messages I should see the following behavior

  • if I set receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE then only 1 message will come back
  • If I set receive_mode=ServiceBusReceiveMode.PEEK_LOCK then up to 100 messages might come back ?

@kashifkhan kashifkhan added the needs-author-feedback More information is needed from author to address the issue. label Aug 18, 2023
@github-actions
Copy link

Hi @lubomirmatus. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the needs-team-triage This issue needs the team to triage. label Aug 18, 2023
@lubomirmatus
Copy link
Author

Hi @kashifkhan

When you have 100 messages in topic:

  • if set receive_mode=ServiceBusReceiveMode.RECEIVE_AND_DELETE then 1st message is consumed (deleted from topic/subscription) and messages 2-100 are returned
  • if set receive_mode=ServiceBusReceiveMode.PEEK_LOCK then all 100 messages are returned and topic/subscription is untached - all messages are still in topic.

@github-actions github-actions bot added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Aug 18, 2023
@kashifkhan
Copy link
Member

Thank you @lubomirmatus . I'm able to reproduce this on my end and will update this thread once we have a fix in place.

@kashifkhan
Copy link
Member

@lubomirmatus just out of curiosity, we were wondering why set RECEIVE_AND_DELETE and then peek messages? PEEK_LOCK and complete messages ( with auto lock renewer) can work similarly

@lubomirmatus
Copy link
Author

I have been performing debugging/tests of our system. In some points of code I wanted to see messages in the topic before they have been received and processed so I used peek to see them but not touch them. The recevier was created with RECEIVE_AND_DELETE mode, I expected that peek_messages does not consume messages, and then I found this strange behaviour.

@kashifkhan
Copy link
Member

Thank you for the update @lubomirmatus . We are able to reproduce this and will update when the fix will go in

@kashifkhan kashifkhan added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 11, 2023
@swathipil
Copy link
Member

Hi @lubomirmatus - We've found the bug and are currently working on the right fix. We'll keep you updated as continue to work on it. Thanks!

More info: Our default prefetch behavior should be "off". However, even when it's off, we're currently prefetching a message.

@swathipil
Copy link
Member

Hi @lubomirmatus - We've merged the fix into the main branch of the repo. We will be releasing the fix this week. If you'd like to test out the change beforehand, you can build the wheel off of the main branch. Thanks!

@swathipil
Copy link
Member

Hi @lubomirmatus - The fix has been released - https://pypi.org/project/azure-servicebus/7.11.3/

Thanks!

@lubomirmatus
Copy link
Author

Ok, thank you.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. 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 Service Bus
Projects
None yet
Development

No branches or pull requests

4 participants