-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
AIO version of EventHubConsumerClient
has significant memory leak
#36398
Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist. |
Hi @smoke - Thanks for opening an issue! Are you using websocket, i.e. passing in TransportType.AmqpOverWebsocket? Or are you using the sample as is without any modifications? |
Hi @smoke. 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. |
Sample as is, with added few lines to send the events through |
@smoke Would you also be able to provide debug level logging to see if the memory jumps correlate with underlying errors?
Pass in |
Hi @smoke. 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. |
This memory leak is also impacting my application (forwarding large JSON audit events from Microsoft Entra to Azure Event Hub). I reproduced the memory leak issue in a scratch environment. To do so, I wrote 200MB of dummy JSON data to a new event hub and downloaded it using the async reference implementation that Smoke linked in the issue. Debug logs from the receiver are attached. Unfortunately, the Sync implementation doesn't work in my environment due to a different issue with our dual-stack TCP outgoing proxy. Please let me know if I can provide any additional context or logging! |
Please find the log file with debug logger debug.log.tar.gz Here a graph of the memory usage that clearly shows the memory leak: Notice that to have realistic scenario I have used the following async def on_event(partition_context, event):
# Put your code here.
# If the operation is i/o intensive, async will have better performance.
print("Received event from partition: {}.".format(partition_context.partition_id))
### changed code starts ###
print('Simulating work') # noqa: T201
await asyncio.sleep(30000)
### changed code finishes ###
await partition_context.update_checkpoint(event) Update: I have tested with code that does not have any additional code and there is no memory leak, apparently the problem is when there is some async code inside the Here the pristine code log |
Hi @smoke, A few questions:
|
|
Hi @smoke we were able to reproduce your issue and are looking into a fix, will update when we have more information. |
Hi @smoke update: we have a fixed merged into main, if you are able to test out those changes by building a whl from there that would help to confirm that your issue has been resolved. If you are unable to, we will update this thread when the fix is released :) |
Hi @smoke. 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 @smoke, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
@l0lawrence I can not do that right now, sorry. Can you link the PR or commit that fixes the issue here, also make sure the issue is properly closed as resolved / fixed?
|
I packaged a new .whl for azure-eventhub from the Main branch (commit ef2521b) and duplicated @smoke's test condition (#36398 (comment)). Memory usage on the latest build is now stable: I would appreciate it if we could cut a release with this patch included- I can't import arbitrary commits into my environment. |
Thanks for testing it out, we will work on getting this released and update you all when it is out. |
Hi @smoke. 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 @smoke and @bretttegart, the fix is out in azure-eventhub 5.12.2. Thanks! |
Describe the bug
AIO version of EventHubConsumerClient has significant memory leak, when async code is used inside
on_event
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Long running events processing to not leak memory.
Screenshots
AIO version memory usage over 12h:
(note the spike downs are POD restarts due to OOM killer)
Sync version memory usage over 12h:
Additional context
For example the sync implementation has no issues at all https://github.dev/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub/samples/sync_samples/recv.py
The text was updated successfully, but these errors were encountered: