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

changefeed,kvClient, sink (ticdc): support bidirectional replication #7630

Merged

Conversation

asddongmen
Copy link
Contributor

@asddongmen asddongmen commented Nov 17, 2022

What problem does this PR solve?

Issue Number: close #7736

What is changed and how it works?

  1. Add BDRMode field to ReplicaConfig to config changefeed for BDR mode.
  2. Add filterLoop field to CDCClient struct, which will be used in cdcpb.ChangeDataRequest to tell the TiKV cdc component to filter rowChange that are written by another TiCDC.
  3. When changefeed is initializing, it will get source_id of the upstream TiDB through PD client, and set it to Sink config.

Note:

  1. When downstream is TiDB, TiCDC will exctue SET SESSION tidb_cdc_write_source = source_id; before commit a txn, which make every txn written by TiCDC has a hidden value tidb_cdc_write_source = source_id. This can help TiKV cdc coponent to decide whether it should ignore a rowChange event.
  2. If the dowstream TiDB does not support tidb_cdc_write_source system variable and the user set bdr-mode = true for a changefeed, create changefeed request will return an error.
  3. Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)
    See test plan for detail.

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Support bidirectional replication.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 17, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3AceShowHand
  • nongfushanquan

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 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 17, 2022
@asddongmen asddongmen changed the title [WIP] kvclient (ticdc): support bidirectional replicating function. [WIP] kvclient (ticdc): support bidirectional replication Nov 18, 2022
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 28, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 28, 2022
@asddongmen asddongmen changed the title [WIP] kvclient (ticdc): support bidirectional replication changefeed,kvClient, sink (ticdc): support bidirectional replication Nov 28, 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 Nov 28, 2022
@@ -501,6 +502,17 @@ LOOP:
cancelCtx, cancel := cdcContext.WithCancel(ctx)
c.cancel = cancel

sourceID, err := pdutil.GetSourceID(ctx, c.upstream.PDClient)
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 not necessary to get sourced if the BDR is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we always need it.

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 28, 2022
cdc/api/v2/model.go Outdated Show resolved Hide resolved
pkg/sink/mysql/config.go Outdated Show resolved Hide resolved
cdc/sink/validator.go Outdated Show resolved Hide resolved
cdc/sink/validator.go Outdated Show resolved Hide resolved
@asddongmen
Copy link
Contributor Author

/run-verify

@asddongmen
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 3994ea0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 30, 2022
@asddongmen
Copy link
Contributor Author

/run-integration-tests tidb=master tikv=master

@asddongmen
Copy link
Contributor Author

/run-engine-integration-test

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Nov 30, 2022
@asddongmen
Copy link
Contributor Author

/run-integration-tests

@asddongmen
Copy link
Contributor Author

/run-integration-tests

@asddongmen
Copy link
Contributor Author

/run-integration-tests

@asddongmen
Copy link
Contributor Author

/run-integration-tests

@asddongmen
Copy link
Contributor Author

/run-integration-tests

@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2022

Codecov Report

Merging #7630 (251c56b) into master (b0f5a0b) will increase coverage by 5.0039%.
The diff coverage is 49.9330%.

Additional details and impacted files
Flag Coverage Δ
cdc 66.2572% <43.4571%> (?)
dm 52.3126% <81.2500%> (+0.1657%) ⬆️
engine 64.3719% <ø> (+0.0873%) ⬆️

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

@@               Coverage Diff                @@
##             master      #7630        +/-   ##
================================================
+ Coverage   55.0067%   60.0106%   +5.0039%     
================================================
  Files           415        812       +397     
  Lines         52739      93930     +41191     
================================================
+ Hits          29010      56368     +27358     
- Misses        20957      32673     +11716     
- Partials       2772       4889      +2117     

@asddongmen
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 6582b3f

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

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

At the same time I will also trigger all tests for you:

/run-all-tests

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 merged commit 3f4a8a7 into pingcap:master Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

ticdc: support bidirectional replication.
7 participants