Skip to content

mgr, osd, mon: remove pg_upmap_primary mappings for PG merge targets - #69272

Merged
ljflores merged 5 commits into
ceph:mainfrom
ljflores:wip-IBMCEPH-9445
Aug 13, 2026
Merged

ljflores merged 5 commits into
ceph:mainfrom
ljflores:wip-IBMCEPH-9445

Conversation

@ljflores

@ljflores ljflores commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

OSDMap::check_pg_upmaps already takes care of removing pg_upmap_primary
mappings for:

  1. PGs that were “merge sources” (PGs that merged into another PG and thus
    no longer exist in the pool)
  2. PGs that are “pending merge” (these PGs will end up becoming merge sources)

But there is a third scenario that was missing for pg_upmap_primary: “merge targets”.

The DaemonServer identifies PGs as “merge targets”, or the PGs that a “merge source”
will merge into. If there is a pg_upmap, pg_upmap_items, or pg_upmap_primary mapping
associated with a “merge target”, the DaemonServer issues this message:

2026-05-14T21:16:56.700+0000 7f745e33d640 10 mgr.server operator() pool 5 pg_num_target
32 pg_num 33 - merge target 5.0 acting does not match (source [3,2,1] != target [3,1,2])

Until the acting set of the “merge target” matches the “merge source”, the merging process
will stall. One way the PG merging process is triggered is by removing the “bulk” flag from a pool.

Removing upmap mappings for “merge target” PGs is not handled in the OSDMap code, but rather, the
DaemonServer code. This patch adds in that missing logic.


This patch also improves the ceph osd rm-pg-upmap-primary-all command so all upmap_primary mappings can be removed on a per-pool basis.

The syntax is:

ceph osd rm-pg-upmap-primary-all <pool name>

This command can be used in a developer or advanced user setting,
but was mainly developed to be used in the DaemonServer code when we remove
mappings on pools where pg_num was adjusted.

Fixes: https://tracker.ceph.com/issues/76731
Signed-off-by: Laura Flores [email protected]

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.

@ljflores
ljflores requested a review from a team as a code owner June 3, 2026 17:44
@ljflores
ljflores marked this pull request as draft June 3, 2026 17:46
@ljflores
ljflores marked this pull request as ready for review July 22, 2026 23:18
@ljflores
ljflores requested a review from a team as a code owner July 22, 2026 23:18
Comment thread src/mon/MonCommands.h Outdated
"clear all pg primary entries (developers only)",
COMMAND("osd rm-pg-upmap-primary-all "
"name=pool,type=CephPoolname,req=false",
"clear all pg primary entries, or all entries for pool <pool> (developers only)",

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.

PG maybe?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will fix once all reviews are complete

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Clarified the language here.

@ljflores

Copy link
Copy Markdown
Member Author

Fixed some minor issues with the script.

@ljflores ljflores added needs-squid-backport PR needs a squid backport needs-tentacle-backport PRs that need tentacle back-port needs-umbrella-backport This PR should be backported to Umbrella labels Jul 23, 2026

@rzarzynski rzarzynski 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.

Overall LGTM! Architecturally it makes sense.
Just a question about potentially missed Fixes tag in one of the commits.

Comment thread src/mon/OSDMonitor.cc
ss << "unrecognized pool name '" << pool_name << "'";
goto reply_no_propose;
}
osdmap.rm_all_upmap_prims(cct, &pending_inc, pool_id);

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.

OK.

Comment thread src/mgr/DaemonServer.cc
const string cmd =
"{"
"\"prefix\": \"osd rm-pg-upmap-primary-all\", "
"\"pool\": \"" + pool_name + "\"" +

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.

Oh, now I see the justification for the making the cmd more flexible. The distinction between simple, low-level logic & more complex buildup outside makes sense to me.

Comment thread src/mgr/DaemonServer.cc
@@ -3302,6 +3302,7 @@ void DaemonServer::adjust_pgs()
std::map<string,unsigned> pg_num_to_set;

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.

Shouldn't the description of this commit also have Fixes: https://tracker.ceph.com/issues/76731?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added this.

ljflores added 4 commits July 24, 2026 19:56
Now, the command `ceph osd rm-pg-upmap-primary-all` can optionally be
run for a specific pool. The syntax is:

`ceph osd rm-pg-upmap-primary-all <pool name>`

This command can be used in a developer or advanced user setting,
but it is also helpful in the DaemonServer code when we remove
mappings on pools where pg_num was adjusted.

I also clarified the descriptions in the pg-upmap-primary CLI
commands.

Fixes: https://tracker.ceph.com/issues/76731
Signed-off-by: Laura Flores <[email protected]>
`OSDMap::check_pg_upmaps` already takes care of removing pg_upmap_primary
mappings for:

1. PGs that were “merge sources” (PGs that merged into another PG and thus
   no longer exist in the pool)
2. PGs that are “pending merge” (these PGs will end up becoming merge sources)

But there is a third scenario that was missing for pg_upmap_primary: “merge targets”.

The DaemonServer identifies PGs as “merge targets”, or the PGs that a “merge source”
will merge into. If there is a pg_upmap, pg_upmap_items, or pg_upmap_primary mapping
associated with a “merge target”, the DaemonServer issues this message:

```
2026-05-14T21:16:56.700+0000 7f745e33d640 10 mgr.server operator() pool 5 pg_num_target
32 pg_num 33 - merge target 5.0 acting does not match (source [3,2,1] != target [3,1,2])
```

Until the acting set of the “merge target” matches the “merge source”, the merging process
will stall. One way the PG merging process is triggered is by removing the “bulk” flag from a pool.

Removing upmap mappings for “merge target” PGs is not handled in the OSDMap code, but rather, the
DaemonServer code. This patch adds in that missing logic.

Fixes: https://tracker.ceph.com/issues/76731
Signed-off-by: Laura Flores <[email protected]>
Add test_read_balancer.sh to the rados teuthology workunits.
The script is used to test any kind of balancer operations, whether it
be via the mgr module or the CLI upmap commands.

TEST_read_balancer_bulk_flag tests the balancer's interaction with the
autoscaler --bulk flag and ensures that pg_upmap_primary mappings are
properly cleared when a pool grows and reduces its pg_num.

TEST_read_balancer_cli verifies the new CLI option to remove pg_upmap_primary
mappings for a single pool: `ceph osd rm-pg-upmpa-primary-all <pool>`.

Also, add a teuthology suite yaml to singleton-nomsgr. The `test_read_balancer.sh`
script does not tolerate msgr error injections, so this is the best
location for it as opposed to the singleton tests.

Fixes: https://tracker.ceph.com/issues/76731
Signed-off-by: Laura Flores <[email protected]>
@ljflores

Copy link
Copy Markdown
Member Author

Changes were to address reviewer's nits. Marking with "needs-qa" now.

@yuriw

yuriw commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri3-testing-20260808.022747-main.

@ljflores
ljflores force-pushed the wip-IBMCEPH-9445 branch 2 times, most recently from 777e0af to 954fede Compare August 10, 2026 22:55
@ljflores ljflores removed the needs-qa label Aug 10, 2026
@ljflores

Copy link
Copy Markdown
Member Author

Taking "needs-qa" off of this as the latest commit is reviewed.

…rations

This test intentially made a test pool scale up and down (via the bulk flag)
so we could verify that the read balancer's `pg_upmap_primary` entires get
properly removed as PGs merge.

Unintentionally, the test caused slow heartbeats because of a large amount of
PG splitting that was happening as the pool scaled up. A large amount of PG
splitting was causing the op threadpool to be consumed for up to 7 minutes,
which exceeded the default osd_op_thread_timeout of 15 seconds and led to
slow heartbeats.

Adjusting `mgr_max_pg_num_change` from 128 to 32 means that there will be less PG
splitting per osdmap epoch, and therefore less consumption on the op threadpool.
Now, it takes only ~7 seconds for PG splitting per epoch.

I also adjusted the `osd_op_thread_timeout` to 60s since, although much
improved, the latest results still showed 2/30 tests failing from slow heartbeats.

See full analysis of this issue here: https://gist.github.com/ljflores/72e66c405aaf2d3e004eddcbc77545bf

Fixes: https://tracker.ceph.com/issues/76731
Signed-off-by: Laura Flores <[email protected]>

@kamoltat kamoltat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for making the change:

I remember there were efforts in preventing pg splitting from jumping too much: #44155. I guess times have changed and maybe the 128 default is too much for certain tests to handle

@ljflores

Copy link
Copy Markdown
Member Author

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants