From 32f1cf1dbe4d9ed3cc31a847e5b87608ede6d636 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Sun, 2 Sep 2018 09:51:40 +0300 Subject: [PATCH] Support for GCP (Google Cloud Platform) --- doc/command-line-flags.md | 8 ++++++++ doc/requirements-and-limitations.md | 3 ++- go/base/context.go | 1 + go/base/utils.go | 3 ++- go/binlog/gomysql_reader.go | 2 +- go/cmd/gh-ost/main.go | 1 + go/logic/applier.go | 2 +- go/logic/inspect.go | 2 +- 8 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/command-line-flags.md b/doc/command-line-flags.md index 4c66add..3df55e0 100644 --- a/doc/command-line-flags.md +++ b/doc/command-line-flags.md @@ -2,6 +2,10 @@ A more in-depth discussion of various `gh-ost` command line flags: implementation, implication, use cases. +### aliyun-rds + +Add this flag when executing on Aliyun RDS. + ### allow-master-master See [`--assume-master-host`](#assume-master-host). @@ -103,6 +107,10 @@ While the ongoing estimated number of rows is still heuristic, it's almost exact Without this parameter, migration is a _noop_: testing table creation and validity of migration, but not touching data. +### gcp + +Add this flag when executing on a 1st generation Google Cloud Platform (GCP). + ### heartbeat-interval-millis Default 100. See [`subsecond-lag`](subsecond-lag.md) for details. diff --git a/doc/requirements-and-limitations.md b/doc/requirements-and-limitations.md index 4415a30..628451d 100644 --- a/doc/requirements-and-limitations.md +++ b/doc/requirements-and-limitations.md @@ -39,7 +39,8 @@ The `SUPER` privilege is required for `STOP SLAVE`, `START SLAVE` operations. Th - For example, you may not migrate `MyTable` if another table called `MYtable` exists in the same schema. - Amazon RDS works, but has it's own [limitations](rds.md). -- Google Cloud SQL is currently not supported +- Google Cloud SQL works, `--gcp` flag required. +- Aliyun RDS works, `--aliyun-rds` flag required. - Multisource is not supported when migrating via replica. It _should_ work (but never tested) when connecting directly to master (`--allow-on-master`) diff --git a/go/base/context.go b/go/base/context.go index 2357c54..0043d07 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -92,6 +92,7 @@ type MigrationContext struct { IsTungsten bool DiscardForeignKeys bool AliyunRDS bool + GoogleCloudPlatform bool config ContextConfig configMutex *sync.Mutex diff --git a/go/base/utils.go b/go/base/utils.go index fc1858d..99536f8 100644 --- a/go/base/utils.go +++ b/go/base/utils.go @@ -75,7 +75,8 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, // swallow this error. not all servers support extra_port } // AliyunRDS set users port to "NULL", replace it by gh-ost param - if migrationContext.AliyunRDS { + // GCP set users port to "NULL", replace it by gh-ost param + if migrationContext.AliyunRDS || migrationContext.GoogleCloudPlatform { port = connectionConfig.Key.Port } else { portQuery := `select @@global.port` diff --git a/go/binlog/gomysql_reader.go b/go/binlog/gomysql_reader.go index a479c99..d2797bb 100644 --- a/go/binlog/gomysql_reader.go +++ b/go/binlog/gomysql_reader.go @@ -145,7 +145,7 @@ func (this *GoMySQLReader) StreamEvents(canStopStreaming func() bool, entriesCha defer this.currentCoordinatesMutex.Unlock() this.currentCoordinates.LogFile = string(rotateEvent.NextLogName) }() - log.Infof("rotate to next log name: %s", rotateEvent.NextLogName) + log.Infof("rotate to next log from %s:%d to %s", this.currentCoordinates.LogFile, int64(ev.Header.LogPos), rotateEvent.NextLogName) } else if rowsEvent, ok := ev.Event.(*replication.RowsEvent); ok { if err := this.handleRowsEvent(ev, rowsEvent, entriesChannel); err != nil { return err diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 30ac436..3024702 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -68,6 +68,7 @@ func main() { flag.BoolVar(&migrationContext.DiscardForeignKeys, "discard-foreign-keys", false, "DANGER! This flag will migrate a table that has foreign keys and will NOT create foreign keys on the ghost table, thus your altered table will have NO foreign keys. This is useful for intentional dropping of foreign keys") flag.BoolVar(&migrationContext.SkipForeignKeyChecks, "skip-foreign-key-checks", false, "set to 'true' when you know for certain there are no foreign keys on your table, and wish to skip the time it takes for gh-ost to verify that") flag.BoolVar(&migrationContext.AliyunRDS, "aliyun-rds", false, "set to 'true' when you execute on Aliyun RDS.") + flag.BoolVar(&migrationContext.GoogleCloudPlatform, "gcp", false, "set to 'true' when you execute on a 1st generation Google Cloud Platform (GCP).") executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit") flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust") diff --git a/go/logic/applier.go b/go/logic/applier.go index ae59f62..ee9e066 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -89,7 +89,7 @@ func (this *Applier) InitDBConnections() (err error) { if err := this.validateAndReadTimeZone(); err != nil { return err } - if !this.migrationContext.AliyunRDS { + if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform { if impliedKey, err := mysql.GetInstanceKey(this.db); err != nil { return err } else { diff --git a/go/logic/inspect.go b/go/logic/inspect.go index dc69b81..ce1fcfb 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -53,7 +53,7 @@ func (this *Inspector) InitDBConnections() (err error) { if err := this.validateConnection(); err != nil { return err } - if !this.migrationContext.AliyunRDS { + if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform { if impliedKey, err := mysql.GetInstanceKey(this.db); err != nil { return err } else {