Repository navigation
mgr/mirroring: fix directory rebalance after mirror daemon restart - #70942
Conversation
|
Will add the qa in the next update. Rebalance succeeded in the local testing after the remaining |
12a017d to
f8a3ab1
Compare
mgr/mirroring should re-shuffle after DIR_SHUFFLE_THROTTLE_INTERVAL interval, right? (defaults to 300s). |
Ideally it should have, but it is not. The throttle interval was introduced in e253f68 and it returns false from |
kotreshhr
left a comment
There was a problem hiding this comment.
Detailed review is still pending
can_shuffle_dir() incorrectly treated DirectoryState as a dict (dir_state['mapped_time']), so rejoin-time shuffle raised TypeError, was swallowed by the Finisher, and left dirs stuck on the surviving daemon. Failover still worked because dead-instance removal force-shuffles without can_shuffle_dir(). Use dir_state.mapped_time. Even with that fix, dirs remapped during failover get a fresh mapped_time and stay under the 300s shuffle throttle, so an immediate add_instances() on rejoin often selects nothing. Shuffle only ran on instance add/remove, so the imbalance could persist indefinitely. After add/remove, if the map is still uneven, schedule a deferred rebalance via rebalance_at — a deadline checked by the existing timer_task / process_updates() upkeep loop — for throttle_remaining() (time until the most recently mapped dir clears the 300s window). When due, rebalance() retries add_instances([]). So after rejoin, reshuffle is either immediate (dirs already past throttle) or automatically once that window elapses. Uneven means max(live dir counts) - min(live dir counts) > 1. For example 5 dirs on 2 daemons can never be "balanced" (always 3+2), so deferred rebalance would keep moving one dir back and forth every throttle period. Allowing a difference of one treats 3+2 as done. Re-arm only while dirs are still throttled or SHUFFLING is in flight. If shuffle returns nothing and the throttle has already elapsed, do not keep a spinning deadline (a no-op that would wake forever without moving dirs); wait for the next instance change instead. Fixes: https://tracker.ceph.com/issues/79010 Signed-off-by: Karthik U S <[email protected]>
f8a3ab1 to
33d4da0
Compare
Add test coverage for mirror directory rebalance across three HA daemons, including initial distribution, failover/rejoin and post-throttle stability checks. After failover, assert directory concentration on surviving instances rather than max-min > 1 — even dir counts can settle evenly on the survivors (e.g. 4 dirs -> [2, 2]). Fixes: https://tracker.ceph.com/issues/79010 Signed-off-by: Karthik U S <[email protected]>
33d4da0 to
f6b7ef6
Compare
|
Ran the mirror-ha test and fixed the issues in the test cases. The latest run looks good: https://pulpito-ng.ceph.com/runs/karthik-us1-2026-11-03_15:47:07-fs:mirror-ha-wip-karthik-us1-70942-mirror-rebalance-issue-2026-11-02-distro-default-trial |
|
This PR has been added to main integration testing by khiremat started 2026-11-01-06:48. |
|
jenkins retest this please |
|
This PR broke teuthology with the Heads up — this file's comment on line 14 has a Unicode em-dash ( # Method paths only — loading the class would also run ~80 inheritedThat breaks Result: the Fix: #73797 |
A Unicode em-dash in a comment on this file (added in ceph#70942) makes teuthology-suite's yaml merge fail with: yaml.reader.ReaderError: unacceptable character #x0080: special characters are not allowed This silently schedules 0 jobs for the fs suite on any branch that carries this file (confirmed on wip-yuri16-testing, SHA1 ffb8c98). Swap the em-dash for a plain hyphen. Signed-off-by: Yuri Weinstein <[email protected]> Assisted-by: Claude Sonnet 5
can_shuffle_dir() incorrectly treated DirectoryState as a dict (dir_state['mapped_time']), so rejoin-time shuffle raised TypeError, was swallowed by the Finisher, and left dirs stuck on the surviving daemon. Failover still worked because dead-instance removal force-shuffles without can_shuffle_dir().
Use dir_state.mapped_time. Even with that fix, dirs remapped during failover get a fresh mapped_time and stay under the 300s shuffle throttle, so an immediate add_instances() on rejoin often selects nothing. Shuffle only ran on instance add/remove, so the imbalance could persist indefinitely.
After add/remove, if the map is still uneven, arm a one-shot deferred rebalance for throttle_remaining() - time until the most recently mapped dir clears the 300s window. When it fires, rebalance() retries add_instances([]). So after rejoin, reshuffle is either immediate (dirs already past throttle) or automatically once that window elapses.
Uneven means max(live dir counts) - min(live dir counts) > 1. For example 5 dirs on 2 daemons can never be "balanced" (always 3+2), so deferred rebalance would keep moving one dir back and forth every throttle period. Allowing a difference of one treats 3+2 as done.
Re-arm only while dirs are still throttled or SHUFFLING is in flight. If shuffle returns nothing and the throttle has already elapsed, do not arm a ~1s retry loop (a no-op spin that wakes forever without moving dirs); wait for the next instance change instead.
Fixes: https://tracker.ceph.com/issues/79010
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.