Skip to content

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

Merged
batrick merged 1 commit into
ceph:tentaclefrom
lumir-sliva:read-balancer-float-tentacle
Oct 9, 2026
Merged

batrick merged 1 commit into
ceph:tentaclefrom
lumir-sliva:read-balancer-float-tentacle

Conversation

@lumir-sliva

Copy link
Copy Markdown
Contributor

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

  • 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)
@lumir-sliva
lumir-sliva requested a review from a team as a code owner September 23, 2026 22:44
@github-actions github-actions Bot added this to the tentacle milestone Sep 23, 2026
@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 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-bharath28-testing-20260924.103245-tentacle.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

@batrick batrick modified the milestones: tentacle, v20.2.5 Oct 9, 2026
@batrick
batrick merged commit 37e259b into ceph:tentacle Oct 9, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved core needs-qa releng-audit-pass Release engineering: passed backport verification audit. tests wip-bharath28-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants