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

dm: new router compatible with regular expression #4358

Merged
merged 16 commits into from
Feb 16, 2022

Conversation

buchuitoudegou
Copy link
Contributor

@buchuitoudegou buchuitoudegou commented Jan 17, 2022

What problem does this PR solve?

implement new router that is compatible with regular expressions

Issue Number: close #4256

What is changed and how it works?

A new router that is compatible with regular expressions is implemented. It basically reused the filter module in tidb-tools project, which has also been used in the block-allow-list. Reusing the existing module ensures modules behaving the same across the whole project.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • New router implemented as a stand-alone module and exporting the same interface with the old one
  • Replace the old router with the new one

Side effects

Related changes

Release note

Implement a new router that is compatible with regular expression as well as the old router

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 17, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • GMHDBJD
  • lance6716

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 do-not-merge/needs-linked-issue first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jan 17, 2022
@CLAassistant
Copy link

CLAassistant commented Jan 17, 2022

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 17, 2022
@buchuitoudegou buchuitoudegou linked an issue Jan 17, 2022 that may be closed by this pull request
@buchuitoudegou buchuitoudegou force-pushed the master branch 2 times, most recently from a2b8e8e to 0040bdc Compare January 18, 2022 02:37
@buchuitoudegou buchuitoudegou changed the title WIP: new router implementation compatible with regular expression WIP: new router compatible with regular expression Jan 18, 2022
@D3Hunter D3Hunter added the area/dm Issues or PRs related to DM. label Jan 18, 2022
@buchuitoudegou buchuitoudegou added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 18, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 18, 2022
@buchuitoudegou buchuitoudegou changed the title WIP: new router compatible with regular expression dm: new router compatible with regular expression Jan 18, 2022
@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 Jan 18, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2022

Codecov Report

Merging #4358 (85dd8ee) into master (9607554) will increase coverage by 0.0075%.
The diff coverage is 62.5546%.

Flag Coverage Δ
cdc 60.3175% <59.3750%> (+0.3953%) ⬆️
dm 51.6932% <63.4388%> (-0.3356%) ⬇️

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

@@               Coverage Diff                @@
##             master      #4358        +/-   ##
================================================
+ Coverage   55.6402%   55.6477%   +0.0075%     
================================================
  Files           494        507        +13     
  Lines         61283      62768      +1485     
================================================
+ Hits          34098      34929       +831     
- Misses        23750      24355       +605     
- Partials       3435       3484        +49     

dm/regexprrouter/router.go Outdated Show resolved Hide resolved
dm/regexprrouter/router.go Outdated Show resolved Hide resolved
dm/regexprrouter/router.go Outdated Show resolved Hide resolved
dm/regexprrouter/router.go Outdated Show resolved Hide resolved
@buchuitoudegou
Copy link
Contributor Author

/run-kafka-integration-test /tidb=pr/30558

@buchuitoudegou
Copy link
Contributor Author

/run-integration-test /tidb=pr/30558

@@ -25,12 +25,12 @@ import (
bf "github.com/pingcap/tidb-tools/pkg/binlog-filter"
"github.com/pingcap/tidb-tools/pkg/column-mapping"
"github.com/pingcap/tidb-tools/pkg/filter"
router "github.com/pingcap/tidb-tools/pkg/table-router"
Copy link
Contributor

Choose a reason for hiding this comment

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

just a question: why not pull a request to tidb-tools?
maybe i miss some offline talk infomation😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, nice suggestion. We're planning moving it to tidb-tools to keep the table router aligned across all the project.

dm/tests/all_mode/run.sh Outdated Show resolved Hide resolved
dm/tests/all_mode/run.sh Outdated Show resolved Hide resolved
dm/pkg/router/router_test.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2022
Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM
Please resolve conflict

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 7, 2022
Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

rest lgtm

dm/pkg/router/router.go Show resolved Hide resolved
dm/pkg/router/router.go Outdated Show resolved Hide resolved
dm/pkg/router/router.go Outdated Show resolved Hide resolved
dm/pkg/router/router.go Outdated Show resolved Hide resolved
dm/pkg/router/router.go Outdated Show resolved Hide resolved
dm/pkg/router/router_test.go Show resolved Hide resolved
{
SchemaPattern: "~s?chema.*",
TargetSchema: "test",
TargetTable: "t2",
Copy link
Contributor

Choose a reason for hiding this comment

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

this usage (no table-pattern but target-table) is strange, should we forbid it in future? @GMHDBJD @lichunzhu

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should forbid this kind of behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if the users would like to migrate all tables from one or more designated schema(s) to exactly ONE table in downstream?

Copy link
Contributor

Choose a reason for hiding this comment

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

They should use TablePattern: "*"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But for now, missing field TablePattern is permitted. Would it be troublesome if we forbid it, considering some users may need to modify their old configs?

dm/pkg/router/router_test.go Show resolved Hide resolved
dm/tests/all_mode/run.sh Outdated Show resolved Hide resolved
dm/tests/all_mode/run.sh Outdated Show resolved Hide resolved
@lance6716
Copy link
Contributor

ping @buchuitoudegou

@buchuitoudegou
Copy link
Contributor Author

/run-all-tests

@buchuitoudegou
Copy link
Contributor Author

/run-verify

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2022
@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 Feb 16, 2022
@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 85dd8ee

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dm Issues or PRs related to DM. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

dm table-routing need support regular expressions
9 participants