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

Support two clusters of bidirectional replication. #864

Closed
wants to merge 6 commits into from

Conversation

freemindLi
Copy link
Contributor

@freemindLi freemindLi commented Jan 3, 2020

What problem does this PR solve?

Support two clusters of bidirectional replication.
A <-> B

What is changed and how it works?

  • surport ddl one-way synchronization
  • surport dml Mutual synchronization

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

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

1.surport ddl one-way synchronization
2.surport dml Mutual synchronization
3.surport cluster A Mutual synchronization B,cluster B Mutual synchronization C,cluster C binlog can sync to A or not sync to A by set channel_id
modify mark table name
1.add create mark table logic
@claassistantio
Copy link

claassistantio commented Jan 3, 2020

CLA assistant check
All committers have signed the CLA.

@IANTHEREAL
Copy link
Collaborator

Cool!Great Work, thanks @freemindLi

@IANTHEREAL
Copy link
Collaborator

IANTHEREAL commented Jan 4, 2020

@july2993 @suzaku PTAL

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.

thanks,
pls address the comment about static lint.
you can run make check local.

pls sign the CLA.

}
}
return dmls
}
func (s *loaderImpl) execDMLs(dmls []*DML) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note this dmls IS NOT the origin txn.
loaderImpl will split the origin txn of TiDB and exec them concurrently.
after splitting some part of dmls will not contains the mark table.
we can check and drop txn before

err = s.dsyncer.Sync(&dsync.Item{Binlog: binlog, PrewriteValue: preWrite})

@@ -595,6 +668,11 @@ func (b *batchManager) execAccumulatedDMLs() (err error) {
}

func (b *batchManager) execDDL(txn *Txn) error {

if !b.ddlSync {
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 handle sync or not sync outside loader in draienr/syncer.go directly?

@july2993 july2993 changed the title AA binlog sync task Support two clusters of bidirectional replication. Jan 6, 2020
return sync
}

func (e *executor) setsyncInfo(sync *syncInfo) *executor {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems that don't need to return executor

@@ -129,6 +132,9 @@ func NewConfig() *Config {
fs.Int64Var(&cfg.InitialCommitTS, "initial-commit-ts", -1, "if drainer donesn't have checkpoint, use initial commitTS to initial checkpoint, will get a latest timestamp from pd if setting to be -1")
fs.StringVar(&cfg.Compressor, "compressor", "", "use the specified compressor to compress payload between pump and drainer, only 'gzip' is supported now (default \"\", ie. compression disabled.)")
fs.IntVar(&cfg.SyncerCfg.TxnBatch, "txn-batch", 20, "number of binlog events in a transaction batch")
fs.BoolVar(&cfg.SyncerCfg.MarkStatus, "mark-status", false, "set mark or not ")
fs.BoolVar(&cfg.SyncerCfg.DdlSync, "ddl-sync", false, "sync ddl or not")
fs.Int64Var(&cfg.SyncerCfg.ChannelId, "channel-id", 0, "sync channel id ")
Copy link
Contributor

Choose a reason for hiding this comment

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

how about adding more details about these three config

@@ -184,6 +184,23 @@ func (dml *DML) updateSQL() (sql string, args []interface{}) {
return
}

func updateMarkSQL(columns []string, Values map[string]interface{}) (string, []interface{}) {

//sql := fmt.Sprintf("REPLACE INTO %s(%s) VALUES(%s)",MarkTableName, buildColumnList(columns),holderString(len(columns)))
Copy link
Contributor

Choose a reason for hiding this comment

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

can delete this line

@@ -65,6 +65,9 @@ type SyncerConfig struct {
IgnoreSchemas string `toml:"ignore-schemas" json:"ignore-schemas"`
IgnoreTables []filter.TableName `toml:"ignore-table" json:"ignore-table"`
TxnBatch int `toml:"txn-batch" json:"txn-batch"`
MarkStatus bool `toml:"mark-status" json:"mark-status"`
DdlSync bool `toml:"ddl-sync" json:"ddl-sync"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@july2993
Copy link
Contributor

july2993 commented Jan 7, 2020

@freemindLi #867 will allow when the column number of downstream table mismatch with current schema. you can help take a look too.

@freemindLi freemindLi closed this Jan 8, 2020
@freemindLi freemindLi mentioned this pull request Jan 9, 2020
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.

7 participants