Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: extract storage operations to schedulerConfig interface #8515

Merged
merged 16 commits into from
Aug 14, 2024

Conversation

okJiang
Copy link
Member

@okJiang okJiang commented Aug 12, 2024

What problem does this PR solve?

Issue Number: Close #8514, ref #8379

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • no

Side effects

  • no

Related changes

  • no

Release note

None.

Signed-off-by: okJiang <819421878@qq.com>
Copy link
Contributor

ti-chi-bot bot commented Aug 12, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 12, 2024
Signed-off-by: okJiang <819421878@qq.com>
Copy link

codecov bot commented Aug 12, 2024

Codecov Report

Attention: Patch coverage is 82.35294% with 24 lines in your changes missing coverage. Please review.

Project coverage is 77.54%. Comparing base (1c1cd99) to head (4ba7249).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8515      +/-   ##
==========================================
+ Coverage   77.40%   77.54%   +0.14%     
==========================================
  Files         473      474       +1     
  Lines       61934    61864      -70     
==========================================
+ Hits        47941    47975      +34     
+ Misses      10409    10356      -53     
+ Partials     3584     3533      -51     
Flag Coverage Δ
unittests 77.54% <82.35%> (+0.14%) ⬆️

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

@okJiang okJiang changed the title scheduler: extract storage operator to schedulerConfig interface scheduler: extract storage operations to schedulerConfig interface Aug 12, 2024
@okJiang okJiang marked this pull request as ready for review August 12, 2024 05:01
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 12, 2024
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
@okJiang
Copy link
Member Author

okJiang commented Aug 12, 2024

/test pull-integration-realcluster-test

Copy link
Member Author

@okJiang okJiang left a comment

Choose a reason for hiding this comment

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

self review

pkg/schedule/schedulers/balance_leader.go Outdated Show resolved Hide resolved
pkg/schedule/schedulers/evict_leader.go Outdated Show resolved Hide resolved
pkg/schedule/schedulers/evict_slow_store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

Is it similar to #7598?

@okJiang
Copy link
Member Author

okJiang commented Aug 12, 2024

Is it similar to #7598?

yes, #7598 wrapped persist only, #8515 wrapped persist and load

Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
@okJiang
Copy link
Member Author

okJiang commented Aug 13, 2024

Could you please take a look? @lhy1024 @rleungx

@@ -120,7 +112,7 @@ func (h *splitBucketHandler) updateConfig(w http.ResponseWriter, r *http.Request
}
newc, _ := json.Marshal(h.conf)
if !bytes.Equal(oldc, newc) {
if err := h.conf.persistLocked(); err != nil {
if err := h.conf.save(h.conf); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It looks strange.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 13, 2024
@@ -79,7 +79,7 @@ func (conf *balanceLeaderSchedulerConfig) update(data []byte) (int, any) {
}
return http.StatusBadRequest, "invalid batch size which should be an integer between 1 and 10"
}
if err := conf.persistLocked(); err != nil {
if err := conf.save(conf); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about conf.save()

Copy link
Member Author

@okJiang okJiang Aug 13, 2024

Choose a reason for hiding this comment

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

If we change it to the form of conf.save(), then we will have to save conf(xxxxxSchedulerConfig) as a pointer(any) in baseSchedulerConfig. I'm not sure if this is a good idea. If everyone agrees, I can make this change.

cc @rleungx

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made this change, we can compare them and choose the best one. 96ef87e

Actually, I also think that save() is better👀

newCfg := &evictSlowTrendSchedulerConfig{}
if err = DecodeConfig([]byte(cfgData), newCfg); err != nil {
if err := s.conf.load(newCfg); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about err, newCfg := s.conf.load()

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to know the structures that need to be decoded, so we have to input them in.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 14, 2024
Copy link
Contributor

ti-chi-bot bot commented Aug 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-13 07:35:53.904483225 +0000 UTC m=+253438.607952860: ☑️ agreed by rleungx.
  • 2024-08-14 02:40:07.426701801 +0000 UTC m=+322092.130171442: ☑️ agreed by lhy1024.

defer handler.config.Unlock()
prevRecoveryDurationGap := handler.config.RecoveryDurationGap

conf := handler.config
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the conf assignment also need to be in the lock scope?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a pointer, so this assignment won't trigger any data reading or writing.

But to avoid similar misunderstandings, I'll revert this change, it won't affect this pull request.

handler.config.Lock()
defer handler.config.Unlock()
prevRecoveryDurationGap := handler.config.RecoveryDurationGap
conf := handler.config
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
Copy link
Contributor

ti-chi-bot bot commented Aug 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lhy1024, niubell, rleungx

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

The pull request process is described here

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 the approved label Aug 14, 2024
@ti-chi-bot ti-chi-bot bot merged commit 3b37572 into tikv:master Aug 14, 2024
21 checks passed
@okJiang okJiang deleted the unify-scheduler-config branch August 14, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm 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.

Extract the storage operation to an interface from scheduler config
4 participants