Repository navigation
tentacle: osd/OSDMap: don't abort on float rounding in read balancer - #72026
Merged
Merged
Conversation
calc_desired_primary_distribution_simple() scales the per-OSD desired primary counts so that they sum to pg_num, then re-sums them into a float and asserts the total is within 0.01 of pg_num. The quantity is an algebraic identity, but the float accumulator rounds once per OSD while the tolerance stays absolute, so the accumulated rounding error exceeds 0.01 on large pools and the assert aborts the active mgr's balancer thread. With the balancer in upmap-read or read mode every standby mgr aborts in turn on its next tick, leaving the cluster with no mgr until the balancer mode is changed. At pg_num 65536 a float only resolves 0.0078125, so the 0.01 tolerance is barely more than one rounding step: on a 60-OSD pool of that size the re-sum lands at 65535.98828125 while distribution_sum and factor are still exactly 65536 and 1.0. The sibling ceph_assert(factor >= 1.0) is fragile the same way: with uniform primary affinity 1 the exact factor is 1.0, and rounding in distribution_sum can push the computed value just below it. Compute the stretch factor and both accumulators in double, tolerate tiny negative rounding on factor before clamping it back to 1.0, and scale the sum tolerance with pg_num. Neither condition is worth aborting the process over: when a check still fails, log it at debug level 10 and return -EINVAL, which the caller already treats as "skip this pool" for the current balancer round. The two new tests use OSD count / pg_num combinations (500/32768 and 100/131072) that deterministically trip the old asserts. Fixes: https://tracker.ceph.com/issues/80443 Reported-by: Armsby Li Signed-off-by: Lumir Sliva <[email protected]> (cherry picked from commit 9425ea2)
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
Contributor
Author
|
@ljflores would you mind having a look please? thank you! |
ljflores
approved these changes
Sep 23, 2026
Contributor
|
This PR has been added to wip-bharath28-testing-20260924.103245-tentacle. |
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.
backport tracker: https://tracker.ceph.com/issues/80816
backport of #71772
parent tracker: https://tracker.ceph.com/issues/80443
this backport was staged manually
Clean cherry-pick of 9425ea2, no conflicts, hunks byte-identical to main.
This is the branch the bug was reported from: the tracker's affected version is
v20.2.4, a 192-OSD cluster that lost every mgr in rotation once the balancer
was put in upmap-read mode. calc_desired_primary_distribution_simple() here is
the same pre-fix code as on main, and the single production caller already maps
a negative return to "skip this pool", so the new -EINVAL path needs no
adaptation.
Built and ran unittest_osdmap on tentacle: 41/41 pass, including the two new
regression tests (read_balance_large_pg_num at 500 OSDs / 32768 PGs and
read_balance_huge_pg_num at 100 / 131072), both of which abort without the fix.
Checklist