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

check-task: precheck server-id for all/incremental mode (#1312) #1315

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions checker/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func ignoreExcept(itemMap map[string]struct{}) []string {
config.DumpPrivilegeChecking,
config.ReplicationPrivilegeChecking,
config.VersionChecking,
config.ServerIDChecking,
config.BinlogEnableChecking,
config.BinlogFormatChecking,
config.BinlogRowImageChecking,
Expand Down Expand Up @@ -145,6 +146,24 @@ func (s *testCheckerSuite) TestVersionChecking(c *tc.C) {
c.Assert(CheckSyncConfig(context.Background(), cfgs), tc.ErrorMatches, "(.|\n)*version required at least .* but got 10.0.0(.|\n)*")
}

func (s *testCheckerSuite) TestServerIDChecking(c *tc.C) {
cfgs := []*config.SubTaskConfig{
{
IgnoreCheckingItems: ignoreExcept(map[string]struct{}{config.ServerIDChecking: {}}),
},
}

mock := s.initMockDB(c)
mock.ExpectQuery("SHOW GLOBAL VARIABLES LIKE 'server_id'").WillReturnRows(sqlmock.NewRows([]string{"Variable_name", "Value"}).
AddRow("server_id", "0"))
c.Assert(CheckSyncConfig(context.Background(), cfgs), tc.ErrorMatches, "(.|\n)*please set server_id greater than 0(.|\n)*")

mock = s.initMockDB(c)
mock.ExpectQuery("SHOW GLOBAL VARIABLES LIKE 'server_id'").WillReturnRows(sqlmock.NewRows([]string{"Variable_name", "Value"}).
AddRow("server_id", "1"))
c.Assert(CheckSyncConfig(context.Background(), cfgs), tc.IsNil)
}

func (s *testCheckerSuite) TestBinlogEnableChecking(c *tc.C) {
cfgs := []*config.SubTaskConfig{
{
Expand Down
3 changes: 3 additions & 0 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ func (c *Checker) Init(ctx context.Context) (err error) {
if _, ok := c.checkingItems[config.VersionChecking]; ok {
c.checkList = append(c.checkList, check.NewMySQLVersionChecker(instance.sourceDB.DB, instance.sourceDBinfo))
}
if _, ok := c.checkingItems[config.ServerIDChecking]; ok {
c.checkList = append(c.checkList, check.NewMySQLServerIDChecker(instance.sourceDB.DB, instance.sourceDBinfo))
}
if _, ok := c.checkingItems[config.BinlogEnableChecking]; ok {
c.checkList = append(c.checkList, check.NewMySQLBinlogEnableChecker(instance.sourceDB.DB, instance.sourceDBinfo))
}
Expand Down
2 changes: 1 addition & 1 deletion checker/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func CheckSyncConfig(ctx context.Context, cfgs []*config.SubTaskConfig) error {
switch cfgs[0].Mode {
case config.ModeFull:
ignoreCheckingItems = append(ignoreCheckingItems, config.ReplicationPrivilegeChecking,
config.BinlogEnableChecking, config.BinlogFormatChecking, config.BinlogRowImageChecking)
config.BinlogEnableChecking, config.BinlogFormatChecking, config.BinlogRowImageChecking, config.ServerIDChecking)
case config.ModeIncrement:
ignoreCheckingItems = append(ignoreCheckingItems, config.DumpPrivilegeChecking)
}
Expand Down
2 changes: 2 additions & 0 deletions dm/config/checking_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
DumpPrivilegeChecking = "dump_privilege"
ReplicationPrivilegeChecking = "replication_privilege"
VersionChecking = "version"
ServerIDChecking = "server_id"
BinlogEnableChecking = "binlog_enable"
BinlogFormatChecking = "binlog_format"
BinlogRowImageChecking = "binlog_row_image"
Expand All @@ -41,6 +42,7 @@ var AllCheckingItems = map[string]string{
DumpPrivilegeChecking: "dump privileges of source DB checking item",
ReplicationPrivilegeChecking: "replication privileges of source DB checking item",
VersionChecking: "MySQL/MariaDB version checking item",
ServerIDChecking: "server_id checking item",
BinlogEnableChecking: "binlog enable checking item",
BinlogFormatChecking: "binlog format checking item",
BinlogRowImageChecking: "binlog row image checking item",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/pingcap/log v0.0.0-20201112100606-8f1e84a3abc8
github.com/pingcap/parser v0.0.0-20201123080035-8f4c6ab94e11
github.com/pingcap/tidb v1.1.0-beta.0.20201119113654-22feeb4aef75
github.com/pingcap/tidb-tools v4.0.7-0.20200927084250-e47e0e12c7f3+incompatible
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible
github.com/prometheus/client_golang v1.5.1
github.com/rakyll/statik v0.1.6
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ github.com/pingcap/tidb-tools v4.0.0+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnw
github.com/pingcap/tidb-tools v4.0.1+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v4.0.5-0.20200820082341-afeaaaaaa153+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v4.0.5-0.20200820092506-34ea90c93237+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v4.0.7-0.20200927084250-e47e0e12c7f3+incompatible h1:4SG8o8YyuhNbiAZS0eyArroyl0EpwbUE9QE6CXzjs6Y=
github.com/pingcap/tidb-tools v4.0.7-0.20200927084250-e47e0e12c7f3+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg=
github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM=
github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330 h1:rRMLMjIMFulCX9sGKZ1hoov/iROMsKyC8Snc02nSukw=
github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330/go.mod h1:RtkHW8WbcNxj8lsbzjaILci01CtYnYbIkQhjyZWrWVI=
github.com/pingcap/tipb v0.0.0-20200417094153-7316d94df1ee h1:XJQ6/LGzOSc/jo33AD8t7jtc4GohxcyODsYnb+kZXJM=
Expand Down