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

mcs: watch rule change with txn #7550

Merged
merged 11 commits into from
Dec 20, 2023
Merged

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Dec 14, 2023

What problem does this PR solve?

Issue Number: Close #7418

What is changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    img_v3_0265_eb742483-9343-4ad9-9353-bbc9f915515g

Release note

None.

Signed-off-by: lhy1024 <admin@liudos.us>
Copy link
Contributor

ti-chi-bot bot commented Dec 14, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

Copy link
Contributor

ti-chi-bot bot commented Dec 14, 2023

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 release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 14, 2023
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Merging #7550 (fc61c05) into master (59c9d04) will decrease coverage by 0.08%.
The diff coverage is 64.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7550      +/-   ##
==========================================
- Coverage   74.80%   74.73%   -0.08%     
==========================================
  Files         457      457              
  Lines       50351    50388      +37     
==========================================
- Hits        37667    37658       -9     
- Misses       9351     9396      +45     
- Partials     3333     3334       +1     
Flag Coverage Δ
unittests 74.73% <64.21%> (-0.08%) ⬇️

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

Signed-off-by: lhy1024 <admin@liudos.us>
}
// Try to add the rule to the patch or directly update the rule manager.
err = func() error {
if rw.patch == nil {
Copy link
Member

Choose a reason for hiding this comment

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

When will this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this pr, it will not use patch when loading data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can only use patch in the all time

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

The rest LGTM

pkg/mcs/scheduling/server/rule/watcher.go Outdated Show resolved Hide resolved
pkg/mcs/scheduling/server/rule/watcher.go Outdated Show resolved Hide resolved
pkg/mcs/scheduling/server/rule/watcher.go Outdated Show resolved Hide resolved
Signed-off-by: lhy1024 <admin@liudos.us>
rule, err := placement.NewRuleFromJSON([]byte(ruleJSON))
if err != nil {
}
postFn := func(events []*clientv3.Event) error {
Copy link
Member

Choose a reason for hiding this comment

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

The postFn may not be executed when calling load.

Signed-off-by: lhy1024 <admin@liudos.us>
log.Error("run pre event failed in watch loop", zap.String("name", lw.name),
zap.String("key", lw.key), zap.Error(err))
}
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

Will it affect the keyspace related logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will check it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR will also call postEventsFn when meeting failures in loading data.

After my check, keyspace-watcher will call postEventsFn to retry, keyspace-server-watcher will call postEventsFn to send keyspaces.

So I modify a little about it.

Copy link
Member

Choose a reason for hiding this comment

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

The return error also changes, right?

@rleungx rleungx marked this pull request as ready for review December 19, 2023 04:23
@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 Dec 19, 2023
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024
Copy link
Contributor Author

lhy1024 commented Dec 19, 2023

These tests will be failed with master branch in api mode

image
image

Signed-off-by: lhy1024 <admin@liudos.us>
return err
}
// Try to add the rule change to the patch.
if err := rw.ruleManager.AdjustRule(rule, ""); 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.

Do we need to parser the group ID and use it for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This pr has used rule.GroupID in value

@@ -865,6 +865,16 @@ func (lw *LoopWatcher) load(ctx context.Context) (nextRevision int64, err error)
if limit != 0 {
limit++
}
if err := lw.preEventsFn([]*clientv3.Event{}); 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 seems that there is no implemented function using the param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used to judge whether is called by watch or by load.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 19, 2023
if isLoading && rw.patch.IsRuleExist(rule) {
log.Error("duplicated rule key", zap.String("rule-key", key), zap.ByteString("rule-value", kv.Value),
errs.ZapError(errs.ErrLoadRule))
return errs.ErrLoadRule
Copy link
Member

Choose a reason for hiding this comment

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

If we return error, the cluster can not be created. Is it expected?

Copy link
Member

Choose a reason for hiding this comment

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

It should be deleted I think.

@@ -129,6 +132,11 @@ func (rw *Watcher) initializeRuleWatcher() error {
if err := rw.ruleManager.AdjustRule(rule, ""); err != nil {
return err
}
if isLoading && rw.patch.IsRuleExist(rule) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check the store key?

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 20, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Dec 20, 2023

/merge

Copy link
Contributor

ti-chi-bot bot commented Dec 20, 2023

@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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 ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented Dec 20, 2023

This pull request has been accepted and is ready to merge.

Commit hash: acacc02

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 20, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 20, 2023

@lhy1024: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit cfbc9b9 into tikv:master Dec 20, 2023
24 of 26 checks passed
@lhy1024 lhy1024 deleted the fix-rule-sync3 branch December 20, 2023 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mcs: inconsistency in watch placement rule
3 participants