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

Error amqp:link:detach-forced causes send_messages to timeout for 7s. #38627

Closed
cabal-daniel opened this issue Nov 20, 2024 · 17 comments
Closed
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Messaging Messaging crew question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@cabal-daniel
Copy link

  • Package Name: azure-servicebus
  • Package Version: 7.13.0
  • Operating System: Ubuntu 20
  • Python Version: python3.12

Describe the bug
We are experiencing a bug where our sender.send_messages are taking longer than 7s to send a message every 10 minutes.

Image

After careful investigation we determined that this line in servicebus.py raises an exception

    @trace_function
    def _send(
        self,
        message: Union[ServiceBusMessage, ServiceBusMessageBatch],
        timeout: Optional[float] = None,
        last_exception: Optional[Exception] = None,  # pylint: disable=unused-argument
    ) -> None:
        self._amqp_transport.send_messages(self, message, _LOGGER, timeout=timeout, last_exception=last_exception)

the exception being

Error condition: amqp:link:detach-forced
Error Description: The link 'G0:38070458:85065d4d-9298-4e43-b9cc-6aba5173f804' is force detached. Code: publisher(link88573). Details: AmqpMessagePublisher.IdleTimerExpired: Idle timeout: 00:10:00.

                                               File /venv/lib/python3.12/site-packages/azure/servicebus/_transport/_pyamqp_transport.py, line 498, in send_messages
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 701, in send_message
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 294, in _do_retryable_operation
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 273, in _do_retryable_operation
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 671, in _send_message_impl
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 406, in client_ready
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 603, in _client_ready
                                                               File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/link.py, line 112, in get_state
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 273, in _do_retryable_operation
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 671, in _send_message_impl
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 406, in client_ready
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 603, in _client_ready
                                                               File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/link.py, line 112, in get_state
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 273, in _do_retryable_operation
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 671, in _send_message_impl
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 406, in client_ready
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 603, in _client_ready
                                                               File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/link.py, line 112, in get_state
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 273, in _do_retryable_operation
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 671, in _send_message_impl
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 406, in client_ready
                                                             File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/client.py, line 603, in _client_ready
                                                               File /venv/lib/python3.12/site-packages/azure/servicebus/_pyamqp/link.py, line 112, in get_state

Which is https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-troubleshoot which does not provide details on how to mitigate this issue.

Our question is can we either prevent this exception from being raised? If not, can we prevent the 7s delays from occurring?

To Reproduce
Steps to reproduce the behavior:

  1. call sender.send_messages with a credential, wait 20 minutes, then do it again.

Expected behavior
The second call should take about the same time as the first call being less than 1s to execute.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 20, 2024
@kashifkhan
Copy link
Member

Thank you for the feedback @cabal-daniel , we will investigate this and get back to you asap.

@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 20, 2024
@kashifkhan
Copy link
Member

Hi @cabal-daniel ,

The reason why the link detaches is because of the 10 min wait. As there is no activity over the connection, the link gets detached and enters our retry loop. In order to keep things happy there is a little bit of exponential back off happening.

You see the following error when the AMQP connection and link are active but no calls (for example, send or receive) are made using the link for 10 minutes. So, the link is closed. The connection is still open.

To get around this you can reduce the number of retries or have something being sent over the sender.

@kashifkhan kashifkhan added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 20, 2024
Copy link

Hi @cabal-daniel. 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.

@jonathan-fileread
Copy link

Hey @kashifkhan - thanks for this. would you recommend reverting to uamqp_protocol=True?
Reducing # of retries reduces resiliency and having something being sent over the sender feels like a anti-pattern (i.e. cronjob or some wake message before send_messages() is triggered in actual workflow)

@cabal-daniel
Copy link
Author

Is there a way to check the connection has been detached and therefore, for a re-open of the connection again? I see that there's a thread that opens up whenever the detach happens. Can we keep a thread to always keep it open?

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

kashifkhan commented Nov 21, 2024

@jonathan-fileread I would suggest going to that as a super super temporary workaround ... uAMQP is only supported for legacy users and it will not be getting latest features/bug fixes.

@cabal-daniel in this case the connection is not detached but the link. As the link has not transferred any data the service detaches, while the connection is still open. Have you disabled keep alive ?

We might have to investigate it a bit further as AMQP can be quite picky at times as to how things happen and the order, along with managing link credits etc

@cabal-daniel
Copy link
Author

We did not disable keep alive. Is it turned off by default? I cannot find documentation on that. How do we make sure keep-alive is on?

@cabal-daniel
Copy link
Author

@kashifkhan any ideas?

@kashifkhan
Copy link
Member

@cabal-daniel as a mitigation uamqp is the way to go. Ill update this thread with the PR to address this in pyAMQP and yall can turn that off then.

@cabal-daniel
Copy link
Author

It doesn't seem to fix the issue. It still times out perioidically for 7s Image

@cabal-daniel
Copy link
Author

'uamqp==1.6.11',

ServiceBusClient(
fully_qualified_namespace=self.fully_qualified_namespace,
credential=self.credential_manager.credential,
logging_enable=True,
uampq_transport=True
)

@l0lawrence
Copy link
Member

l0lawrence commented Nov 25, 2024

Hi @cabal-daniel, is this directly copied from your code?

ServiceBusClient( fully_qualified_namespace=self.fully_qualified_namespace, credential=self.credential_manager.credential, logging_enable=True, uampq_transport=True )

If so could you change uampq_transport to uamqp_transport?

@kashifkhan kashifkhan added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Dec 2, 2024
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

Hi @cabal-daniel. 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.

@cabal-daniel
Copy link
Author

Hi @l0lawrence you are right thanks for correcting that mistake. It seems to be working fine now.

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Dec 2, 2024
@l0lawrence
Copy link
Member

l0lawrence commented Jan 24, 2025

Hi @cabal-daniel this has been addressed in pyAMQP and a fix will be out in the next release.

@l0lawrence l0lawrence added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Jan 24, 2025
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 24, 2025
Copy link

Hi @cabal-daniel. 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.

Copy link

Hi @cabal-daniel, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Messaging Messaging crew question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

5 participants