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

Add sync mode config to allow mismatch column number #867

Merged
merged 3 commits into from
Jan 10, 2020

Conversation

july2993
Copy link
Contributor

@july2993 july2993 commented Jan 7, 2020

What problem does this PR solve?

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

What is changed and how it works?

Add a config item sync-mode
when setting SyncPartialColumn will allow mismatch column number
and relax sql mode by removing STRICT_TRANS_TABLES.

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

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

when setting SyncPartialColumn will allow mismatch column number
and relax sql mode by removing STRICT_TRANS_TABLES.
@july2993 july2993 changed the title Add sync mode config Add sync mode config to allow mismatch column number Jan 7, 2020
@july2993 july2993 requested review from suzaku and zier-one January 7, 2020 08:37
Copy link
Contributor

@zier-one zier-one left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Could you provide more context about this change? For example, when would the number of columns in downstream be different from the upstream.

@@ -55,6 +56,27 @@ func NewMysqlSyncer(cfg *DBConfig, tableInfoGetter translator.TableInfoGetter, w
}))
}

if cfg.SyncMode != 0 {
mode := loader.SyncMode(cfg.SyncMode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make sure sqlMode don't include STRICT_TRANS_TABLES before creating db?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if sqlMode is not configred we need to create db first by checking the sql mode default of the database.

drainer/sync/mysql.go Show resolved Hide resolved
@july2993
Copy link
Contributor Author

july2993 commented Jan 9, 2020

Could you provide more context about this change? For example, when would the number of columns in downstream be different from the upstream.

description of pr updated

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
Copy link
Contributor Author

/run-all-tests

@july2993 july2993 merged commit 43fb818 into pingcap:master Jan 10, 2020
@july2993 july2993 deleted the mismatch_col branch January 10, 2020 03:20
july2993 added a commit to july2993/tidb-binlog that referenced this pull request Jan 15, 2020
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
@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.

3 participants