Repository navigation
Add primary range repair type - #2021
Merged
Merged
Conversation
Add repair type PRIMARY_RANGE (primary_range in the configuration), for scheduled and on-demand repairs. Every managed node runs a full repair of all its primary ranges in one repair session, like nodetool repair -pr. Locks: the single slot table lock that incremental repair takes, so the two exclude each other per table, and one single slot lock per datacenter involved, named PrimaryRange-<datacenter> so it does not collide with the vnode datacenter lock. No per-node locks, repair.lock_type does not apply, and it is not coordinated with vnode repair. History: the task records repair_history rows typed PRIMARY_RANGE, keyed by the coordinator node. They are read with the new RepairHistoryProvider.lastSuccessfulRepair, which does not map rows to token ranges, and the vnode repair state reader now skips them explicitly instead of dropping full-range rows by accident. First repair: a table with no primary range repair in the history is taken for a new table, as for vnode repair, so its first repair waits for initial_delay. A history that cannot be read is not taken for no history, so a failing read does not delay a repair. On demand: a cluster-wide request already creates one job per managed node, so OngoingJob.startClusterWideJob writes no extra rows for this type, which would have run every repair twice. Every repair type dispatch point handles the new type explicitly, as required by the exhaustive switches from #1989. Unit tests pin the lock sets, the history separation and the per-type behavior. Integration tests: test_primary_range_repair.py runs scheduled and on-demand primary range repairs on a 4 node, 2 datacenter cluster. It checks that the coordinators repair disjoint token ranges, that the history is recorded as PRIMARY_RANGE and read back after a restart, and that the repair needs the table lock and both datacenter locks but not the vnode locks. It runs as a suite of its own, in the new primary-range-repair-integration-tests profile and its local variant, which are split off from the incremental repair profiles and added to the CI workflow and scripts/run-ci.sh, together with the incremental suites that run-ci.sh was missing. Its cluster-free helpers are unit tested in the Python unit tests job. A behave scenario covers run-repair with the new type. Alarms: a scheduled primary range job raises REPAIR_WARNING and REPAIR_ERROR at repair.alarm.warn and repair.alarm.error, using the threshold decision now shared with vnode repair (AlarmPostUpdateHook. faultCodeFor). The alarms carry the source PRIMARY_RANGE_ELAPSED so they do not collide with the vnode alarms of the same node and table. The reporter is only told when an alarm appears, escalates or clears, and the alarm is ceased when a repair succeeds or is found in the history. Issue #2005
jwaeab
approved these changes
Nov 27, 2026
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.
Add repair type PRIMARY_RANGE (primary_range in the configuration), for scheduled and on-demand repairs. Every managed node runs a full repair of all its primary ranges in one repair session, like nodetool repair -pr.
Locks: the single slot table lock that incremental repair takes, so the two exclude each other per table, and one single slot lock per datacenter involved, named PrimaryRange- so it does not collide with the vnode datacenter lock. No per-node locks, repair.lock_type does not apply, and it is not coordinated with vnode repair.
History: the task records repair_history rows typed PRIMARY_RANGE, keyed by the coordinator node. They are read with the new RepairHistoryProvider.lastSuccessfulRepair, which does not map rows to token ranges, and the vnode repair state reader now skips them explicitly instead of dropping full-range rows by accident.
First repair: a table with no primary range repair in the history is taken for a new table, as for vnode repair, so its first repair waits for initial_delay. A history that cannot be read is not taken for no history, so a failing read does not delay a repair.
On demand: a cluster-wide request already creates one job per managed node, so OngoingJob.startClusterWideJob writes no extra rows for this type, which would have run every repair twice.
Every repair type dispatch point handles the new type explicitly, as required by the exhaustive switches from #1989. Unit tests pin the lock sets, the history separation and the per-type behavior.
Integration tests: test_primary_range_repair.py runs scheduled and on-demand primary range repairs on a 4 node, 2 datacenter cluster. It checks that the coordinators repair disjoint token ranges, that the history is recorded as PRIMARY_RANGE and read back after a restart, and that the repair needs the table lock and both datacenter locks but not the vnode locks. It runs as a suite of its own, in the new primary-range-repair-integration-tests profile and its local variant, which are split off from the incremental repair profiles and added to the CI workflow and scripts/run-ci.sh, together with the incremental suites that run-ci.sh was missing. Its cluster-free helpers are unit tested in the Python unit tests job. A behave scenario covers run-repair with the new type.
Alarms: a scheduled primary range job raises REPAIR_WARNING and REPAIR_ERROR at repair.alarm.warn and repair.alarm.error, using the threshold decision now shared with vnode repair (AlarmPostUpdateHook. faultCodeFor). The alarms carry the source PRIMARY_RANGE_ELAPSED so they do not collide with the vnode alarms of the same node and table. The reporter is only told when an alarm appears, escalates or clears, and the alarm is ceased when a repair succeeds or is found in the history.
Issue #2005