Skip to content

umbrella: osd/OSDMap: don't abort on float rounding in read balancer - #72027

Merged
batrick merged 1 commit into
ceph:umbrellafrom
lumir-sliva:read-balancer-float-umbrella
Oct 28, 2026
Merged

batrick merged 1 commit into
ceph:umbrellafrom
lumir-sliva:read-balancer-float-umbrella

Conversation

@lumir-sliva

Copy link
Copy Markdown
Contributor

backport tracker: https://tracker.ceph.com/issues/80815


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.
Umbrella was branched before the fix landed, so it carries the pre-fix
calc_desired_primary_distribution_simple() unchanged: float factor, float
distribution_sum_desired, fixed 0.01 tolerance, both ceph_asserts. The single
production caller already treats a negative return as "skip this pool".

Built and ran unittest_osdmap on umbrella: 43/43 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

  • 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)
    • Includes unit test(s)
    • Includes integration test(s)
    • Includes bug reproducer
    • No tests

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)
@github-actions

Copy link
Copy Markdown

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 ci-approved to allow Jenkins CI jobs to run.

@github-actions github-actions Bot added this to the umbrella milestone Sep 23, 2026
@github-actions github-actions Bot added the releng-audit-pass Release engineering: passed backport verification audit. label Sep 23, 2026
@lumir-sliva

Copy link
Copy Markdown
Contributor Author

@ljflores would you mind having a look please? thank you!

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath27-testing-20260924.224940-umbrella.

@ronen-fr

Copy link
Copy Markdown
Contributor

@batrick batrick modified the milestones: umbrella, v21.2.1 Oct 28, 2026
@batrick
batrick merged commit b6b3fe9 into ceph:umbrella Oct 28, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved core Rados-Tested releng-audit-pass Release engineering: passed backport verification audit. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants