-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Fix memory leak in exception handling (Issue #8882) #9799
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
Conversation
dd72947 to
33c7a22
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9799 +/- ##
==========================================
- Coverage 78.62% 78.62% -0.01%
==========================================
Files 153 153
Lines 19178 19201 +23
Branches 2540 2547 +7
==========================================
+ Hits 15078 15096 +18
- Misses 3809 3812 +3
- Partials 291 293 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
- Enhanced traceback cleanup in celery/app/trace.py to prevent memory leaks - Added proper cleanup of ExceptionInfo objects and traceback references - Optimized traceback_clear() function by removing redundant f_locals access - Added comprehensive memory leak test suite in t/integration/test_memory_leak_8882.py - Fixed code quality issues: removed unused imports, cleaned whitespace, added noqa comments Memory usage improvement: 92% reduction (from ~70MB to ~0.6MB for 500 failing tasks) Addresses reference cycles that prevent garbage collection of traceback frames. All pre-commit hooks passing.
a749037 to
1ca9ff4
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks @auvipy for adding the Copilot review and providing feedback. I've addressed the comments. Let me know if you have any other suggestions. Thanks! |
…neshs21/celery into fix-memory-leak-issue-8882
|
btw unit tests are separated from integration tests |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…neshs21/celery into fix-memory-leak-issue-8882
Got it, Separated the unit and integration tests and moved them to their respective locations. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
auvipy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good
Summary
This PR fixes a critical memory leak in Celery's exception handling that was causing significant memory growth when tasks raise unhandled exceptions.
Problem
Issue #8882 reported that Celery tasks raising unhandled exceptions were causing memory leaks:
Closes #8882
This PR addresses a critical memory leak in Celery's exception handling by breaking reference cycles in tracebacks, ensuring frame locals are cleared, and adding comprehensive tests to verify the fix.