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

binlog loop back sync #879

Merged
merged 21 commits into from
Jan 14, 2020
Merged

binlog loop back sync #879

merged 21 commits into from
Jan 14, 2020

Conversation

freemindLi
Copy link
Contributor

@freemindLi freemindLi commented Jan 9, 2020

recreate of #864

What problem does this PR solve?

In the AA dual activity scenario, there is data write (DML) on both sides. The data of tidb cluster on both sides needs to be synchronized with each other,but avoid loopback synchronization,and ddl is only writed one side.

What is changed and how it works?

add three variables in drainer.toml as identification to confirm need sync ddl or not and need set sync mark identification or not and sync identification id to Avoid loopback synchronization
add configuration item
loopback-control (true/false) set mark table identification or not and filter txn by mark table
ddl-sync (true/false) sync ddl to downstream DB or not
channel-id (integer) sync identification id,avoid loopback synchronization

Check List

Tests

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to be included in the release note

Nihao123451 and others added 12 commits January 3, 2020 10:28
@freemindLi freemindLi reopened this Jan 9, 2020
@freemindLi freemindLi closed this Jan 9, 2020
@freemindLi freemindLi reopened this Jan 9, 2020
@july2993
Copy link
Contributor

july2993 commented Jan 9, 2020

/run-all-tests
@freemindLi you can just add a comment like this to trigger all the tests

don't recreate pr so we can keep and trace the review comments.

Copy link
Contributor Author

@freemindLi freemindLi left a comment

Choose a reason for hiding this comment

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

fix go test bug

Copy link
Contributor Author

@freemindLi freemindLi left a comment

Choose a reason for hiding this comment

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

/run-all-tests

@freemindLi
Copy link
Contributor Author

/run-all-tests

drainer/loopbacksync/loopbacksync.go Outdated Show resolved Hide resolved
drainer/syncer.go Show resolved Hide resolved
drainer/syncer.go Outdated Show resolved Hide resolved
drainer/syncer.go Outdated Show resolved Hide resolved
pkg/loader/executor.go Outdated Show resolved Hide resolved
pkg/loader/load.go Outdated Show resolved Hide resolved
pkg/loader/load.go Outdated Show resolved Hide resolved
pkg/loader/load.go Outdated Show resolved Hide resolved
pkg/loader/load.go Outdated Show resolved Hide resolved
drainer/sync/mysql.go Outdated Show resolved Hide resolved
Copy link
Contributor

@july2993 july2993 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
please resolve conflicts

we should add a simple integration test. maybe in another pr, I will help do it.

drainer/syncer.go Outdated Show resolved Hide resolved
pkg/loader/model.go Outdated Show resolved Hide resolved
@july2993 july2993 requested a review from suzaku January 12, 2020 13:18
drainer/syncer.go Outdated Show resolved Hide resolved
@suzaku
Copy link
Contributor

suzaku commented Jan 13, 2020

Please resolve the conflict.

cmd/drainer/drainer.toml Outdated Show resolved Hide resolved
cmd/drainer/drainer.toml Show resolved Hide resolved
pkg/loader/model_test.go Show resolved Hide resolved
drainer/syncer.go Outdated Show resolved Hide resolved
drainer/syncer.go Outdated Show resolved Hide resolved
pkg/loader/executor.go Outdated Show resolved Hide resolved
pkg/loader/executor.go Outdated Show resolved Hide resolved
pkg/loader/load.go Outdated Show resolved Hide resolved
Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	pkg/loader/load.go
@freemindLi
Copy link
Contributor Author

fix code format and fix some bugs;Resolving conflicts

@freemindLi
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@july2993 july2993 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

cmd/drainer/drainer.toml Outdated Show resolved Hide resolved
drainer/loopbacksync/loopbacksync.go Outdated Show resolved Hide resolved
pkg/loader/executor.go Outdated Show resolved Hide resolved
pkg/loader/executor.go Outdated Show resolved Hide resolved
2.rename stream_info to channel_info
3.delete updateMark function status param
4.adjust column hard code to const reference
@freemindLi
Copy link
Contributor Author

1.adjust explanatory note for sync-ddl,loopback-control and channel-id
2.rename stream_info to channel_info
3.delete updateMark function status param
4.adjust column hard code to const reference

@freemindLi
Copy link
Contributor Author

/run-all-tests

@july2993 july2993 requested a review from suzaku January 14, 2020 01:08
Copy link
Contributor

@july2993 july2993 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
@suzaku PTAL

@freemindLi
Copy link
Contributor Author

1.adjust TestUpdateMarkSQL function logic

@freemindLi
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

LGTM
@suzaku PTAL

pkg/loader/model_test.go Outdated Show resolved Hide resolved
@freemindLi
Copy link
Contributor Author

remove comment line

@freemindLi
Copy link
Contributor Author

/run-all-tests

1 similar comment
@july2993
Copy link
Contributor

/run-all-tests

Copy link
Contributor

@suzaku suzaku left a comment

Choose a reason for hiding this comment

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

LGTM

@july2993 july2993 merged commit d42bd56 into pingcap:master Jan 14, 2020
july2993 pushed a commit to july2993/tidb-binlog that referenced this pull request Jan 15, 2020
In the AA dual activity scenario, there is data write (DML) on both sides. The data of tidb cluster on both sides needs to be synchronized with each other,but avoid loopback synchronization,and ddl is only writed one side.

add three variables in drainer.toml as identification to confirm need sync ddl or not and need set sync mark identification or not and sync identification id to Avoid loopback synchronization
add configuration item
loopback-control (true/false) set mark table identification or not and filter txn by mark table
ddl-sync (true/false) sync ddl to downstream DB or not
channel-id (integer) sync identification id,avoid loopback synchronization

Co-authored-by: Nihao123451 <37206498+Nihao123451@users.noreply.github.com>
@july2993 july2993 mentioned this pull request Jan 15, 2020
july2993 added a commit that referenced this pull request Jan 15, 2020
* Add sync mode config (#867)

allow when the column number of downstream table mismatch with current schema.

For the case bidirectional replication, we will execute the DDL at one side, for add or drop column
the column number will mismatch.

cluster A <-> cluster B

drop column of table t at cluster A
some DML of table t at cluster B will miss the column dropped compared to cluster A

* binlog loop back sync (#879)

In the AA dual activity scenario, there is data write (DML) on both sides. The data of tidb cluster on both sides needs to be synchronized with each other,but avoid loopback synchronization,and ddl is only writed one side.

add three variables in drainer.toml as identification to confirm need sync ddl or not and need set sync mark identification or not and sync identification id to Avoid loopback synchronization
add configuration item
loopback-control (true/false) set mark table identification or not and filter txn by mark table
ddl-sync (true/false) sync ddl to downstream DB or not
channel-id (integer) sync identification id,avoid loopback synchronization

Co-authored-by: Nihao123451 <37206498+Nihao123451@users.noreply.github.com>

Co-authored-by: freemindLi <59459626+freemindLi@users.noreply.github.com>
Co-authored-by: Nihao123451 <37206498+Nihao123451@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants