Repository navigation
mgr: free erased MgrMapCache python objects - #72727
Merged
NitzanMordhai merged 2 commits intoNov 1, 2026
Merged
NitzanMordhai merged 2 commits into
NitzanMordhai merged 2 commits into
Conversation
NitzanMordhai
force-pushed
the
wip-nitzan-mgr-cache-leak-with-prometheus
branch
from
October 15, 2026 09:48
7eb391d to
6005e59
Compare
sseshasa
reviewed
Oct 21, 2026
sseshasa
left a comment
Contributor
There was a problem hiding this comment.
Code changes LGTM. The only major comment is around the enhancement of the existing unit test if feasible.
MgrMapCache<PyObject*>::erase() and insert() dropped erased, replaced and evicted entries through Py_AddPendingCall(). That only queues the call for the main thread of the main interpreter, and the ceph-mgr main thread never runs Python, so the queue is never drained; once it is full the call fails and erase() ignored the failure. Either way every erased entry kept its reference. With prometheus scraping a 10K PG cluster, each invalidated pg_dump leaked about 90MB and the mgr grew ~400MB per minute. erase() runs from notify paths that hold ActivePyModules::lock without the GIL, so queue the objects there and drop them on the next get() or insert(), which already require the GIL. insert() now drops replaced and evicted entries directly. Fixes: https://tracker.ceph.com/issues/81794 Signed-off-by: Nitzan Mordechai <[email protected]> Assisted-by: Claude
NitzanMordhai
force-pushed
the
wip-nitzan-mgr-cache-leak-with-prometheus
branch
from
October 21, 2026 12:51
6005e59 to
457cf4a
Compare
sseshasa
approved these changes
Oct 21, 2026
sseshasa
left a comment
Contributor
There was a problem hiding this comment.
LGTM and approving. Please consider adding a couple of additional tests as mentioned in my latest comment.
| Py_DECREF(a); | ||
| Py_DECREF(b); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
-
How about a test that perform repeated
insert(),get()anderase()pattern in a loop many times mimicking the tracker's Prometheus sequence? This would be a reproducer for the tracker. -
Also, a small concurrent test to verify that the locking mechanism is sound would help.
The test commit can be squashed with the main commit.
Check the refcount of cached python objects after insert, get, replace, evict, erase and clear. The erase tests release the GIL before erase(), as the notify paths do, and check that the object is only dropped on the next get() or insert(). These fail on the old Py_AddPendingCall() code. Give the test its own main() that calls global_init, since the MgrMapCache constructor reads g_conf(). Fixes: https://tracker.ceph.com/issues/81794 Signed-off-by: Nitzan Mordechai <[email protected]> Assisted-by: Claude
NitzanMordhai
force-pushed
the
wip-nitzan-mgr-cache-leak-with-prometheus
branch
from
October 21, 2026 15:48
457cf4a to
83d7870
Compare
Contributor
|
This PR has been added to wip-bharath10-testing-20261027.070130-main. |
Tanguille
added a commit
to Tanguille/cluster
that referenced
this pull request
Oct 29, 2026
The active mgr grew ~230 MiB/h on 21.2.0 and OOMed at its 2Gi limit every ~8.5h. Upstream fix is ceph/ceph#72727.
Contributor
Author
4 of 14 tasks
4 of 14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MgrMapCache<PyObject*>::erase() and insert() dropped erased, replaced and evicted entries through Py_AddPendingCall(). That only queues the call for the main thread of the main interpreter, and the ceph-mgr main thread never runs Python, so the queue is never drained; once it is full the call fails and erase() ignored the failure. Either way every erased entry kept its reference. With prometheus scraping a 10K PG cluster, each invalidated pg_dump leaked about 90MB and the mgr grew ~400MB per minute.
erase() runs from notify paths that hold ActivePyModules::lock without the GIL, so queue the objects there and drop them on the next get() or insert(), which already require the GIL. insert() now drops replaced and evicted entries directly.
Fixes: https://tracker.ceph.com/issues/81794
Assisted-by: Claude
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.