Skip to content

scheduler, evict-slow-store allow draining multiple store from AZ#11047

Open
HaoW30 wants to merge 5 commits into
tikv:masterfrom
HaoW30:hw-evict-slow-score-ci
Open

scheduler, evict-slow-store allow draining multiple store from AZ#11047
HaoW30 wants to merge 5 commits into
tikv:masterfrom
HaoW30:hw-evict-slow-score-ci

Conversation

@HaoW30

@HaoW30 HaoW30 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: Close #10742
This is to address the comment for PR #10743 while the original author is away.
Please reference the original PR for previous discussions.

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Please see #10743

  • No code

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Summary by CodeRabbit

  • New Features

    • Added grouped disk slow-store eviction based on configurable failure-domain labels.
    • Added support for configuring, viewing, and reloading group-eviction labels through scheduler settings.
    • Slow stores in the same configured domain can now be evicted together while protecting healthy domains.
    • Recovery now waits for the affected group to return to a healthy state before restoring stores.
  • Bug Fixes

    • Improved handling of store removal, topology changes, persistence failures, and incomplete recovery during eviction.

Tema and others added 5 commits May 29, 2026 18:45
Signed-off-by: artem_danilov <artem.danilov@airbnb.com>
Signed-off-by: artem_danilov <artem.danilov@airbnb.com>
Signed-off-by: artem_danilov <artem.danilov@airbnb.com>
Signed-off-by: artem_danilov <artem.danilov@airbnb.com>
@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jul 23, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yisaer for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. dco-signoff: no Indicates the PR's author has not signed dco. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jul 23, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Hi @HaoW30. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot

ti-chi-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • 3a49d03 use StoreStateFilter to do target store checks
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The evict-slow-store scheduler now supports label-driven group eviction, multi-store persistence, topology safety checks, grouped recovery, and HTTP configuration updates. Unit and cluster tests cover same-domain draining, cross-domain protection, reconciliation, recovery, and persistence.

Changes

Grouped slow-store eviction

Layer / File(s) Summary
Configuration and eviction state
pkg/schedule/schedulers/evict_slow_store.go
Adds group-eviction-labels, parses and exposes configured labels, persists multi-store eviction sets, and supports rollback, removal, and clearing of evicted stores.
Group detection and reconciliation
pkg/schedule/schedulers/evict_slow_store.go
Selects compatible same-domain slow stores, checks healthy-domain capacity, drains leaders as a group, freezes expansion when topology changes, and releases stores after group recovery.
Scheduler and cluster validation
pkg/schedule/schedulers/evict_slow_store_test.go, server/cluster/cluster_test.go
Validates set-based persistence, grouped eviction scenarios, topology and recovery guards, store removal, idempotency, and HTTP-configured end-to-end behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant StoreHeartbeat
  participant EvictSlowStoreScheduler
  participant ClusterStore
  StoreHeartbeat->>EvictSlowStoreScheduler: Update slow-store score
  EvictSlowStoreScheduler->>ClusterStore: Inspect labels and healthy stores
  ClusterStore-->>EvictSlowStoreScheduler: Return domain and topology state
  EvictSlowStoreScheduler->>EvictSlowStoreScheduler: Select compatible eviction group
  EvictSlowStoreScheduler->>ClusterStore: Persist evicted stores and drain leaders
Loading

Possibly related PRs

  • tikv/pd#10946: Connects to the evicted slow-store state consumed by leader-target filtering.

Suggested reviewers: jmpotato, rleungx

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: evict-slow-store now supports draining multiple stores from the same AZ.
Description check ✅ Passed The description follows the template and includes the required issue reference plus change, tests, and checklist sections.
Linked Issues check ✅ Passed The changes implement AZ-group eviction, recovery gating, and conservative fallbacks required by #10742.
Out of Scope Changes check ✅ Passed The added config, API, persistence, and test updates are all directly related to the AZ group-eviction feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/schedule/schedulers/evict_slow_store.go`:
- Around line 573-576: Update cleanupEvictLeader’s error path after
clearEvictedAndPersist to include the returned err in the log entry, while
retaining the existing store-ids field and message context.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7eeeffa8-25d0-4aff-8571-4cab918129b6

📥 Commits

Reviewing files that changed from the base of the PR and between f7db425 and 3a49d03.

📒 Files selected for processing (3)
  • pkg/schedule/schedulers/evict_slow_store.go
  • pkg/schedule/schedulers/evict_slow_store_test.go
  • server/cluster/cluster_test.go

Comment on lines +573 to 576
evictSlowStores, err := s.conf.clearEvictedAndPersist()
if err != nil {
log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64("store-id", evictSlowStore))
log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64s("store-ids", evictSlowStores))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Log the persist error in cleanupEvictLeader. On failure clearEvictedAndPersist returns nil, err, so this log emits empty store-ids and, more importantly, drops the actual error — making a real persistence failure hard to diagnose.

🪵 Include the error
 	evictSlowStores, err := s.conf.clearEvictedAndPersist()
 	if err != nil {
-		log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64s("store-ids", evictSlowStores))
+		log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64s("store-ids", evictSlowStores), zap.Error(err))
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
evictSlowStores, err := s.conf.clearEvictedAndPersist()
if err != nil {
log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64("store-id", evictSlowStore))
log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64s("store-ids", evictSlowStores))
}
evictSlowStores, err := s.conf.clearEvictedAndPersist()
if err != nil {
log.Info("evict-slow-store-scheduler persist config failed", zap.Uint64s("store-ids", evictSlowStores), zap.Error(err))
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/schedule/schedulers/evict_slow_store.go` around lines 573 - 576, Update
cleanupEvictLeader’s error path after clearEvictedAndPersist to include the
returned err in the log entry, while retaining the existing store-ids field and
message context.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.70044% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.29%. Comparing base (bde1fe9) to head (3a49d03).
⚠️ Report is 76 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11047      +/-   ##
==========================================
+ Coverage   79.16%   79.29%   +0.12%     
==========================================
  Files         536      542       +6     
  Lines       73609    76271    +2662     
==========================================
+ Hits        58273    60479    +2206     
- Misses      11235    11526     +291     
- Partials     4101     4266     +165     
Flag Coverage Δ
unittests 79.29% <83.70%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LykxSassinator

Copy link
Copy Markdown
Contributor

Pls check the previous unresolved comments in the original PR, thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. dco-signoff: no Indicates the PR's author has not signed dco. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

evict-slow-store: allow draining multiple nodes from the same availability zone

3 participants