diff --git a/_utils/terror_gen/errors_release.txt b/_utils/terror_gen/errors_release.txt index 093f01b38b..9d003bd3e6 100644 --- a/_utils/terror_gen/errors_release.txt +++ b/_utils/terror_gen/errors_release.txt @@ -173,6 +173,7 @@ ErrTaskCheckGenTableRouter,[code=26003:class=task-check:scope=internal:level=med ErrTaskCheckGenColumnMapping,[code=26004:class=task-check:scope=internal:level=medium], "Message: generate column mapping error, Workaround: Please check the `column-mappings` config in task configuration file." ErrTaskCheckSyncConfigError,[code=26005:class=task-check:scope=internal:level=medium], "Message: %s: %v\n detail: %v" ErrTaskCheckGenBAList,[code=26006:class=task-check:scope=internal:level=medium], "Message: generate block allow list error, Workaround: Please check the `block-allow-list` config in task configuration file." +ErrSourceCheckGTID,[code=26007:class=task-check:scope=internal:level=medium], "Message: %s has GTID_MODE = %s instead of ON, Workaround: Please check the `enable-gtid` config in source configuration file." ErrRelayParseUUIDIndex,[code=28001:class=relay-event-lib:scope=internal:level=high], "Message: parse server-uuid.index" ErrRelayParseUUIDSuffix,[code=28002:class=relay-event-lib:scope=internal:level=high], "Message: UUID (with suffix) %s not valid" ErrRelayUUIDWithSuffixNotFound,[code=28003:class=relay-event-lib:scope=internal:level=high], "Message: no UUID (with suffix) matched %s found in %s, all UUIDs are %v" diff --git a/dm/config/source_config.go b/dm/config/source_config.go index 920cd11e79..141780864f 100644 --- a/dm/config/source_config.go +++ b/dm/config/source_config.go @@ -241,6 +241,16 @@ func (c *SourceConfig) Adjust(db *sql.DB) (err error) { } } + if c.EnableGTID { + val, err := utils.GetGTID(db) + if err != nil { + return err + } + if val != "ON" { + return terror.ErrSourceCheckGTID.Generate(c.SourceID, val) + } + } + return nil } diff --git a/dm/master/server.go b/dm/master/server.go index e607b8ffdf..fab9b2fede 100644 --- a/dm/master/server.go +++ b/dm/master/server.go @@ -1351,6 +1351,7 @@ func parseAndAdjustSourceConfig(contents []string) ([]*config.SourceConfig, erro if _, err = cfg.Yaml(); err != nil { return cfgs, err } + cfgs[i] = cfg } return cfgs, nil diff --git a/errors.toml b/errors.toml index a74e017974..3d04e376a8 100644 --- a/errors.toml +++ b/errors.toml @@ -1048,6 +1048,12 @@ description = "" workaround = "Please check the `block-allow-list` config in task configuration file." tags = ["internal", "medium"] +[error.DM-task-check-26007] +message = "%s has GTID_MODE = %s instead of ON" +description = "" +workaround = "Please check the `enable-gtid` config in source configuration file." +tags = ["internal", "medium"] + [error.DM-relay-event-lib-28001] message = "parse server-uuid.index" description = "" diff --git a/pkg/terror/error_list.go b/pkg/terror/error_list.go index 0cd7d039ac..1e448d7bec 100644 --- a/pkg/terror/error_list.go +++ b/pkg/terror/error_list.go @@ -238,6 +238,7 @@ const ( codeTaskCheckGenColumnMapping codeTaskCheckSyncConfigError codeTaskCheckGenBAList + codeSourceCheckGTID ) // Relay log utils error code @@ -811,6 +812,7 @@ var ( ErrTaskCheckGenColumnMapping = New(codeTaskCheckGenColumnMapping, ClassTaskCheck, ScopeInternal, LevelMedium, "generate column mapping error", "Please check the `column-mappings` config in task configuration file.") ErrTaskCheckSyncConfigError = New(codeTaskCheckSyncConfigError, ClassTaskCheck, ScopeInternal, LevelMedium, "%s: %v\n detail: %v", "") ErrTaskCheckGenBAList = New(codeTaskCheckGenBAList, ClassTaskCheck, ScopeInternal, LevelMedium, "generate block allow list error", "Please check the `block-allow-list` config in task configuration file.") + ErrSourceCheckGTID = New(codeSourceCheckGTID, ClassTaskCheck, ScopeInternal, LevelMedium, "%s has GTID_MODE = %s instead of ON", "Please check the `enable-gtid` config in source configuration file.") // Relay log basic API error ErrRelayParseUUIDIndex = New(codeRelayParseUUIDIndex, ClassRelayEventLib, ScopeInternal, LevelHigh, "parse server-uuid.index", "") diff --git a/pkg/terror/terror.go b/pkg/terror/terror.go index 42419c556f..b5a96c3815 100644 --- a/pkg/terror/terror.go +++ b/pkg/terror/terror.go @@ -38,6 +38,7 @@ const ( ClassBinlogOp ClassCheckpoint ClassTaskCheck + ClassSourceCheck ClassRelayEventLib ClassRelayUnit ClassDumpUnit @@ -59,6 +60,7 @@ var errClass2Str = map[ErrClass]string{ ClassBinlogOp: "binlog-op", ClassCheckpoint: "checkpoint", ClassTaskCheck: "task-check", + ClassSourceCheck: "source-check", ClassRelayEventLib: "relay-event-lib", ClassRelayUnit: "relay-unit", ClassDumpUnit: "dump-unit", diff --git a/pkg/utils/db.go b/pkg/utils/db.go index 8d43994380..1389bbeced 100644 --- a/pkg/utils/db.go +++ b/pkg/utils/db.go @@ -403,3 +403,9 @@ func IsErrBinlogPurged(err error) bool { func IsNoSuchThreadError(err error) bool { return IsMySQLError(err, tmysql.ErrNoSuchThread) } + +// GetGTID return GTID_MODE +func GetGTID(db *sql.DB) (string, error) { + val, err := GetGlobalVariable(db, "GTID_MODE") + return val, err +}