Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

binlog replication: support GTID #521

Merged
merged 37 commits into from
Mar 9, 2020
Merged

binlog replication: support GTID #521

merged 37 commits into from
Mar 9, 2020

Conversation

WangXiangUSTC
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC commented Mar 6, 2020

What problem does this PR solve?

syncer unit support GTID

What is changed and how it works?

  1. add new struct Location to save binlog position and gtid set
  2. use Location in syncer unit

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Breaking backward compatibility

Related changes

  • Need to be included in the release note

@WangXiangUSTC WangXiangUSTC added the status/WIP This PR is still work in progress label Mar 6, 2020
@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

pkg/binlog/position.go Show resolved Hide resolved
syncer/status.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint.go Outdated Show resolved Hide resolved
syncer/checkpoint_test.go Outdated Show resolved Hide resolved
syncer/sharding_group.go Outdated Show resolved Hide resolved
syncer/sharding_group.go Show resolved Hide resolved
syncer/sharding-meta/shardmeta.go Outdated Show resolved Hide resolved
syncer/streamer_controller.go Outdated Show resolved Hide resolved
syncer/syncer_test.go Outdated Show resolved Hide resolved
syncer/syncer_test.go Outdated Show resolved Hide resolved
@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

syncer/syncer.go Outdated Show resolved Hide resolved
syncer/syncer.go Outdated Show resolved Hide resolved
syncer/syncer.go Outdated Show resolved Hide resolved
@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

1 similar comment
@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

@csuzhangxc @lichunzhu PTAL

Copy link
Contributor

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

if binlog.ComparePosition(pos, minCheckpoint) > 0 {
cp.globalPoint = newBinlogPoint(pos, nil, pos, nil)
if binlog.CompareLocation(location, binlog.NewLocation(cp.cfg.Flavor)) > 0 {
cp.globalPoint = newBinlogPoint(location, location, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we create another location to avoid the reuse of GTIDSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all addressed in 53bef75

@@ -640,7 +659,7 @@ func (cp *RemoteCheckPoint) Load(tctx *tcontext.Context, schemaTracker *schema.T
mSchema = make(map[string]*binlogPoint)
cp.points[cpSchema] = mSchema
}
mSchema[cpTable] = newBinlogPoint(pos, &ti, pos, &ti)
mSchema[cpTable] = newBinlogPoint(location, location, &ti, &ti)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

if err != nil {
return err
}
case config.ModeIncrement:
// load meta from task config
if cp.cfg.Meta == nil {
cp.logCtx.L().Warn("don't set meta in increment task-mode")
location1 := binlog.NewLocation(cp.cfg.Flavor)
cp.globalPoint = newBinlogPoint(location1, location1, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

if pos != nil {
cp.globalPoint = newBinlogPoint(*pos, nil, *pos, nil)
if location != nil {
cp.globalPoint = newBinlogPoint(*location, *location, nil, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

dm/worker/worker.go Outdated Show resolved Hide resolved
pkg/binlog/position.go Outdated Show resolved Hide resolved
cp.Lock()
defer cp.Unlock()
cp.saveTablePoint(sourceSchema, sourceTable, pos, ti)
cp.saveTablePoint(sourceSchema, sourceTable, point, ti)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to do Clone for the passed in point? it seems some of the callers do the Clone, but some don't. If so, ditto for other exported methods like SaveGlobalPoint.

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, I haven't unified the usage for Clone, maybe it's better to let the caller to decide whether to allow the function to update the value, if not allowed, can use Clone.
I add a Clone here, maybe we can unified the usage later.

Copy link
Member

Choose a reason for hiding this comment

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

OK, it's fine.

syncer/checkpoint_test.go Show resolved Hide resolved
syncer/sharding-meta/shardmeta.go Outdated Show resolved Hide resolved
syncer/sharding-meta/shardmeta.go Outdated Show resolved Hide resolved
@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests tidb=release-3.0

@WangXiangUSTC
Copy link
Contributor Author

@lichunzhu @csuzhangxc PTAL again

Copy link
Member

@csuzhangxc csuzhangxc left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

@csuzhangxc csuzhangxc added priority/important Major change, requires approval from ≥2 primary reviewers status/LGT1 One reviewer already commented LGTM and removed status/PTAL This PR is ready for review. Add this label back after committing new changes labels Mar 9, 2020
Copy link
Contributor

@lichunzhu lichunzhu left a comment

Choose a reason for hiding this comment

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

LGTM

@lichunzhu lichunzhu added status/LGT2 Two reviewers already commented LGTM, ready for merge and removed status/LGT1 One reviewer already commented LGTM labels Mar 9, 2020
@lichunzhu lichunzhu merged commit 8ff04d2 into master Mar 9, 2020
@WangXiangUSTC WangXiangUSTC deleted the xiang/support_GTID branch March 16, 2020 04:05
lichunzhu pushed a commit to lichunzhu/dm that referenced this pull request Apr 6, 2020
* add new struct Location to save binlog position and gtid set
* use Location in syncer unit
lichunzhu pushed a commit to lichunzhu/dm that referenced this pull request Apr 6, 2020
* add new struct Location to save binlog position and gtid set
* use Location in syncer unit
lichunzhu pushed a commit to lichunzhu/dm that referenced this pull request Apr 7, 2020
* add new struct Location to save binlog position and gtid set
* use Location in syncer unit
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority/important Major change, requires approval from ≥2 primary reviewers status/LGT2 Two reviewers already commented LGTM, ready for merge type/feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants