Skip to content

mgr: add an osd_map_pools getter for rbd_support - #72719

Open
anthonyeleven wants to merge 1 commit into
ceph:mainfrom
anthonyeleven:wip-mgr-osd-map-pools
Open

anthonyeleven wants to merge 1 commit into
ceph:mainfrom
anthonyeleven:wip-mgr-osd-map-pools

Conversation

@anthonyeleven

@anthonyeleven anthonyeleven commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/81783

The mirror snapshot and trash purge schedule handlers in rbd_support each call get_rbd_pools once a minute, even when no schedules exist. get_rbd_pools fetches osd_map only to read pool ids, names and applications.

Dumping osd_map holds the GIL while it converts every OSD and every pg_upmap_items entry to Python objects. It also computes a read balance score for each replicated pool, and each score copies the OSDMap and maps every PG of the pool. On a Reef cluster with 10,130 pg_upmap_items entries, Python module commands stalled for about 6 seconds every 66 seconds.

This gives OSDMap::dump_pool() a with_read_balance parameter, as #73045 does, and adds an osd_map_pools getter that returns the list of pools, dumped through dump_pool() without the read balance scores. get_rbd_pools and TaskHandler.resolve_pool_name use the getter. Other modules that only need pools, such as the prometheus module's get_rbd_stats, could use it too.

The new key is not added to the mgr API cache, since dumping only the pools is cheap.

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Signed-off-by: Anthony D'Atri [email protected]
Assisted by Claude Opus-5.5

@anthonyeleven
anthonyeleven marked this pull request as ready for review October 16, 2026 02:32
@anthonyeleven
anthonyeleven requested review from a team as code owners October 16, 2026 02:32

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumping osd_map holds the GIL while it converts every OSD and every pg_upmap_items entry to Python objects. It also computes a read balance score for each replicated pool, and each score copies the OSDMap and maps every PG of the pool.

Isn't the Python object representation of osd_map as a whole supposed to be cached by MgrMapCache which is enabled by default (mgr_map_cache_enabled config option)?

static const std::unordered_set<std::string> mgr_cache_keys = {
  "osd_map", "pg_dump", "pg_stats", "mon_status", "mgr_map",
  "osd_metadata", "mds_metadata", "config"
};

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@idryomov Good question. MgrMapCache came in with 403340b, which is on main and umbrella but not tentacle or reef. The stalls in the description are from Reef 18.2.8, where the only cache is the old TTL cache and mgr_ttl_cache_expire_seconds defaults to 0, so every call pays for the full dump. That also holds on tentacle, one of the two backport targets.

Where MgrMapCache is enabled, ActivePyModules::notify_all invalidates it on every osd_map notify, so it only helps between epochs. In a five-minute sample on the cluster in question the osdmap moved twice, so roughly every second or third rbd_support call still rebuilds the full dump under the GIL, read balance scores included. rbd_support needs only pool ids, names and applications, so the pools-only getter avoids that cost whether or not the cache is warm.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@idryomov gentle ping: does the reply above answer your MgrMapCache question? Since MgrMapCache isn't in tentacle or reef and is invalidated on every osdmap change, the pools-only getter still saves the full dump there.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@idryomov Another gentle ping on the MgrMapCache question above. #73045, now approved, leaves the read balance scores out of the osd_map getter, but get_rbd_pools still converts every OSD and pg_upmap_items entry each minute. On tentacle and reef nothing caches that dump, so the pools-only getter still saves it there.

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since MgrMapCache isn't in tentacle or reef and is invalidated on every osdmap change, the pools-only getter still saves the full dump there.

Speaking about main and umbrella, is the "invalidated on every osdmap change" a problem? If the manager calling OSDMap::dump() once per epoch and caching the result shows up on any profile, something is seriously wrong with OSDMap::dump().

Reef is EOL, but this looks fine to be merged and backported all the way up to squid.

Comment thread src/mgr/ActivePyModules.cc Resolved
Comment thread src/pybind/mgr/rbd_support/common.py Resolved
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Thanks for taking the time on this one. The cache is a very new feature that hasn't had much shakeout yet. On Umbrella 21.2.0 it made the active mgr grow by about 1 GB an hour, and the advice on the list was to set mgr_map_cache_enabled to false: https://lists.ceph.io/hyperkitty/list/[email protected]/thread/WT7NTYUUL6HMJ5CGHRP6BHRJ3W37JUHN/. The leak fix, #72727, merged on main on 11-01, but its umbrella backport is still open, and clusters that turned the cache off are likely to leave it off for a while. On those, every osd_map fetch dumps the whole map again. So we'd like to go ahead with merging this one: it doesn't hurt to be tidy and efficient when we can. I've made both of your changes; details inline.

Comment thread src/mgr/ActivePyModules.cc Resolved
Comment thread src/mgr/ActivePyModules.cc Resolved
Comment thread src/mgr/ActivePyModules.cc Resolved

@idryomov idryomov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash everything into a single commit. Otherwise LGTM!

anthonyeleven added a commit to anthonyeleven/ceph that referenced this pull request Nov 4, 2026
ceph#73044 removes the OSDMap copies that calc_read_balance_score() and
get_pgs_by_osd() make, so drop "copy the map" from the osd_map getter
comment. This is the wording Ilya Dryomov suggested on ceph#72719.

Fixes: https://tracker.ceph.com/issues/82063
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@idryomov Squashed into a single commit, 6338400, with the same tree as before.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath20-testing-20261109.055221-main.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

The mirror snapshot and trash purge schedule handlers in rbd_support
each call get_rbd_pools once a minute, even when no schedules exist.
get_rbd_pools fetches osd_map only to read pool ids, names and
applications. Dumping osd_map holds the GIL while it converts every OSD
and every pg_upmap_items entry to Python objects. On a cluster with
10,000 pg_upmap_items entries this stalled other mgr modules for about
6 seconds each minute, before ceph#73045 took the read balance scores out
of the osd_map getter.

Add an osd_map_pools getter that returns the list of pools in osd_map,
each dumped by OSDMap::dump_pool() without the read balance scores, and
use it in get_rbd_pools and resolve_pool_name.

Fixes: https://tracker.ceph.com/issues/81783
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

1 similar comment
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants