-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Azure Service Bus SDK - long running process and failed lock renewal process/closed handler #35717
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @EldertGrootenboer. |
Thank you for the feedback @gpiotrowski . We will investigate and get back to you asap. |
@gpiotrowski Would you also be able to provide DEBUG level logs with frame level logging turned on please? This way we can see the interaction between the client and service. import logging
import sys
handler = logging.StreamHandler(stream=sys.stdout)
logger = logging.getLogger('azure.servicebus')
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
...
from azure.servicebus import ServiceBusClient
client = ServiceBusClient(..., logging_enable=True) For the issue around authentication please make sure that either mechanism has the proper access rights Connection String - Manage level - https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string |
Hi @gpiotrowski. 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. |
Hi @kashifkhan, sure! You could find log here: logging-enabled.log. It was test run using connection string with Both mechanisms have proper access rights - for connection string it is |
@gpiotrowski I was able to reproduce this on my end and am working on a PR to address it. Ill update the issue when we have it ready for release |
Hi @gpiotrowski. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation. |
Hi @gpiotrowski, since you haven’t asked that we |
Hi @kashifkhan I am also facing same issue for my long running processes. I am unable to install pre release packages using command "pip install --pre azure-servicebus==7.12.3". It throws error. Also when I am trying to install "pip install --pre azure-servicebus=7.13.0b1", it does not have this fix implemented. Could you please help me regarding this. |
Hi @cgoma, the version with the fix has not been released yet. We will update this thread when it is |
There are so many threads on this issue, so I am posting it here only. Spent hours to find the cause 😔
I pull a large number of messages that take a while to process. The renewer starts to process when only 10s are remaining (which is too late) because there is a funny "sleep" of 0.5 seconds between each message. It would be great if you could let a configurable value be put against the _renew_period -> maybe up to a minute. |
Also, why can't a larger lock duration ( > 5m) be put in the ServiceBus::Queue itself? This seems like such a roundabout and has a potential for errors. |
@tj--- could you please share a code sample of what you are running where you are hitting issues with renewing the locks, as well as the size of the messages you are receiving? |
I'll give you pseudo code, as the actual code is part of my project distributed across modules. Pseudo Code:
|
@tj--- we believe we fixed this problem for the original issue. We plan on releasing the fix officially next week but in the mean time you could build a wheel from main and see if it resolves your scenario. |
If you are referring to this: #35889, I don't think it addresses this problem. |
@tj please go ahead and open a new issue please, attach DEBUG logs with frame level logging as described here #35717 (comment) |
Hmm, okay, will do. But it's very easy to reproduce using the pseudocode I provided. |
@cgoma @gpiotrowski the fix is now in pypi |
Describe the bug
My message consumer is a long running process. From time to time it have a problem with renewing message lock and after that with completing/rejecting that message. I started to investigate possible reasons for that and this is my findings:
ServiceBusClient.from_connection_string(conn_str=connection_string)
) andazure-identity
library (ServiceBusClient(host_name, credential=DefaultAzureCredential())
- in both cases that error appearsleep()
)asyncio
withawait asyncio.sleep()
andsleep()
13:43:21,774
. Message lock renewal failed at14:48:45,475
with information about unauthorized access. This suggest that it happens when token is expired during that long running process. Previous point looks very similar when we sum the times. First and second message took in total 43 minutes. Next message took 28 minutes - during that time token probably expired.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Application will behave the same way no mater how long consumer will take. Refreshing tokens (if this is the issue) should be handled correctly during long running operations.
Additional context
Currently I handle that situation by reconnecting to the Azure Service Bus in case of any errors and subscribe to messages one more time. Additionaly I implement inbox to know which messages were already processed (from application perspective, not broker). But this is workaround that will works only if I will have one instance of the consumer. If I will have multiple instances then when lock renewal process fail other instance will take the same message for processing when the first consumer is still working on it. Inbox will not help in that situation.
I attach full logs from sample run (processing time set to 75 minutes): log.log
The text was updated successfully, but these errors were encountered: