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(ticdc): add package keyspan #7731

Merged
merged 7 commits into from
Dec 9, 2022

Conversation

overvenus
Copy link
Member

What problem does this PR solve?

Issue Number: ref #7720

What is changed and how it works?

Add Reconciler reconciles span and table mapping, make sure spans are in a desired state and covers all table ranges.

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

None

@overvenus overvenus added component/scheduler TiCDC inner scheduler component. area/ticdc Issues or PRs related to TiCDC. labels Nov 28, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 28, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3AceShowHand
  • asddongmen

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.

@ti-chi-bot ti-chi-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 Nov 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2022

Codecov Report

Merging #7731 (58f7258) into master (6d24a57) will increase coverage by 0.0937%.
The diff coverage is 74.6198%.

Additional details and impacted files
Flag Coverage Δ
cdc 66.4522% <78.0185%> (+0.1503%) ⬆️
dm 52.1377% <55.9006%> (-0.0475%) ⬇️
engine 64.1650% <91.6666%> (+0.1682%) ⬆️

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

@@               Coverage Diff                @@
##             master      #7731        +/-   ##
================================================
+ Coverage   59.9034%   59.9972%   +0.0937%     
================================================
  Files           810        817         +7     
  Lines         93255      93856       +601     
================================================
+ Hits          55863      56311       +448     
- Misses        32535      32666       +131     
- Partials       4857       4879        +22     

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 2, 2022
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus force-pushed the span-replication/keyspan branch from 58f7258 to 30e0feb Compare December 6, 2022 08:30
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2022
@overvenus overvenus marked this pull request as ready for review December 6, 2022 08:30
@ti-chi-bot ti-chi-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 6, 2022
// 4. Add table by DDL.
// 5. Drop table by DDL.
// 6. Some captures fail, does NOT affect spans.
func (m *Reconciler) Reconcile(
Copy link
Contributor

Choose a reason for hiding this comment

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

The method looks quite complicated, is it possible to split it into multiple small methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in performance critical path, splitting to multiple methods may lower its speed.
See https://gist.github.com/overvenus/475b333c7726a97d051e01484deb0bf0

}

func (m *Reconciler) splitSpan(ctx context.Context, span tablepb.Span) []tablepb.Span {
bo := tikv.NewBackoffer(ctx, 500)
Copy link
Contributor

@3AceShowHand 3AceShowHand Dec 6, 2022

Choose a reason for hiding this comment

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

can we move the bo into the methods belonging to the regionCache ?

This makes the signature simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

The RegionCache here must be the same as tikv.RegionCache, so that TiCDC compiles.

compat *compat.Compat,
) []tablepb.Span {
tablesLenEqual := len(currentTables) == len(m.tableSpans)
tablesAllFind := true
Copy link
Member

Choose a reason for hiding this comment

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

the name tablesAllFind is confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

Any suggestion? How about allTablsFound?

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 7, 2022
// and for all tables in currentTables have a record in tableSpan.
if !tablesLenEqual || !tablesAllFind {
// The two sets are not identical. We need to find removed tables.
intersectionTable := make(map[model.TableID]struct{}, len(currentTables))
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to extract some func for set operation, it will be easy to test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out we do not to find intersect tables. No more set operation now.

@overvenus
Copy link
Member Author

/run-all-tests

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 8, 2022
@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

overvenus commented Dec 8, 2022

/merge

(This PR is essentially dead code for now, does not relate to tests failure)

@ti-chi-bot
Copy link
Member

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

Commit hash: 3ba052f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Dec 8, 2022
@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-engine-integration-test
/run-integration-test

@overvenus
Copy link
Member Author

/run-engine-integration-test

@ti-chi-bot
Copy link
Member

@overvenus: 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.

@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-integration-test
/run-dm-integration-test

@ti-chi-bot ti-chi-bot merged commit 91f5506 into pingcap:master Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. component/scheduler TiCDC inner scheduler component. 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.

6 participants