Skip to content

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

Merged
batrick merged 1 commit into
ceph:squidfrom
lumir-sliva:read-balancer-float-squid
Oct 27, 2026
Merged

batrick merged 1 commit into
ceph:squidfrom
lumir-sliva:read-balancer-float-squid

Conversation

@lumir-sliva

Copy link
Copy Markdown
Contributor

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


backport of #71772
parent tracker: https://tracker.ceph.com/issues/80443

this backport was staged manually

Clean cherry-pick of 9425ea2, no conflicts. The hunks are byte-identical to
the ones that went into main, only the line offsets move.

calc_desired_primary_distribution_simple() is unchanged on squid: same float
factor, same float distribution_sum_desired, same fixed 0.01 tolerance and the
same two ceph_asserts. The single production caller already treats a negative
return as "skip this pool" for the round, so the new -EINVAL path behaves here
exactly as it does on main. Both triggering balancer modes (upmap-read, read)
exist on this branch, so the mgr abort is reachable.

Built and ran unittest_osdmap on squid: 40/40 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.

One scheduling note: squid's target_eol in doc/releases/releases.yml is
2026-10-31, so this pick has about five weeks of window left.

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

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 squid 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-bharath26-testing-20260924.011509-squid.

@Naveenaidu

Copy link
Copy Markdown
Contributor

RADOS Approved: https://tracker.ceph.com/issues/80823#note-4

@batrick batrick modified the milestones: squid, v19.2.8 Oct 27, 2026
@batrick
batrick merged commit e414058 into ceph:squid Oct 27, 2026
20 of 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-bharath26-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants