From 9d055dbda716734c5c72f16e96926a0af7465324 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Mon, 16 May 2016 11:09:17 +0200 Subject: [PATCH] renaming to gh-ost --- README.md | 2 +- build.sh | 12 ++++----- go/base/context.go | 6 ++--- go/base/utils.go | 2 +- go/binlog/binlog_dml_event.go | 4 +-- go/binlog/binlog_entry.go | 4 +-- go/binlog/binlog_reader.go | 2 +- go/binlog/binlog_test.go | 2 +- go/binlog/gomysql_reader.go | 6 ++--- go/binlog/mysqlbinlog_reader.go | 4 +-- go/binlog/mysqlbinlog_reader_test.go | 2 +- go/cmd/gh-osc/main.go | 16 +++++------ go/logic/applier.go | 40 ++++++++++++++-------------- go/logic/inspect.go | 18 ++++++------- go/logic/migrator.go | 10 +++---- go/logic/streamer.go | 10 +++---- go/mysql/binlog.go | 2 +- go/mysql/connection.go | 2 +- go/mysql/instance_key.go | 2 +- go/mysql/instance_key_map.go | 2 +- go/mysql/utils.go | 2 +- go/os/process.go | 2 +- go/sql/builder.go | 14 +++++----- go/sql/builder_test.go | 32 +++++++++++----------- go/sql/types.go | 2 +- go/sql/types_test.go | 2 +- 26 files changed, 101 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index 1d2e813..2fb5fc3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# gh-osc +# gh-ost GitHub's Online Schema Change for MySQL diff --git a/build.sh b/build.sh index 2041f2e..25265b1 100644 --- a/build.sh +++ b/build.sh @@ -2,19 +2,19 @@ # # -buildpath=/tmp/gh-osc -target=gh-osc +buildpath=/tmp/gh-ost +target=gh-ost timestamp=$(date "+%Y%m%d%H%M%S") mkdir -p ${buildpath} -gobuild="go build -o $buildpath/$target go/cmd/gh-osc/main.go" +gobuild="go build -o $buildpath/$target go/cmd/gh-ost/main.go" echo "Building OS/X binary" echo "GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild" | bash -(cd $buildpath && tar cfz ./gh-osc-binary-osx-${timestamp}.tar.gz $target) +(cd $buildpath && tar cfz ./gh-ost-binary-osx-${timestamp}.tar.gz $target) echo "Building linux binary" echo "GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 $gobuild" | bash -(cd $buildpath && tar cfz ./gh-osc-binary-linux-${timestamp}.tar.gz $target) +(cd $buildpath && tar cfz ./gh-ost-binary-linux-${timestamp}.tar.gz $target) echo "Binaries found in:" -ls -1 $buildpath/gh-osc-binary*${timestamp}.tar.gz +ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz diff --git a/go/base/context.go b/go/base/context.go index 4a7029e..3a2cbfb 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package base @@ -13,8 +13,8 @@ import ( "sync/atomic" "time" - "github.com/github/gh-osc/go/mysql" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/mysql" + "github.com/github/gh-ost/go/sql" "gopkg.in/gcfg.v1" ) diff --git a/go/base/utils.go b/go/base/utils.go index 5fcd713..ef82462 100644 --- a/go/base/utils.go +++ b/go/base/utils.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package base diff --git a/go/binlog/binlog_dml_event.go b/go/binlog/binlog_dml_event.go index 069b0a5..4fab87a 100644 --- a/go/binlog/binlog_dml_event.go +++ b/go/binlog/binlog_dml_event.go @@ -1,13 +1,13 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog import ( "fmt" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/sql" "strings" ) diff --git a/go/binlog/binlog_entry.go b/go/binlog/binlog_entry.go index 961c530..bb70bc5 100644 --- a/go/binlog/binlog_entry.go +++ b/go/binlog/binlog_entry.go @@ -1,13 +1,13 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog import ( "fmt" - "github.com/github/gh-osc/go/mysql" + "github.com/github/gh-ost/go/mysql" ) // BinlogEntry describes an entry in the binary log diff --git a/go/binlog/binlog_reader.go b/go/binlog/binlog_reader.go index 6d07320..fa8e62e 100644 --- a/go/binlog/binlog_reader.go +++ b/go/binlog/binlog_reader.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog diff --git a/go/binlog/binlog_test.go b/go/binlog/binlog_test.go index 75cca90..4abf88f 100644 --- a/go/binlog/binlog_test.go +++ b/go/binlog/binlog_test.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog diff --git a/go/binlog/gomysql_reader.go b/go/binlog/gomysql_reader.go index 4a0b586..88a48d5 100644 --- a/go/binlog/gomysql_reader.go +++ b/go/binlog/gomysql_reader.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog @@ -8,8 +8,8 @@ package binlog import ( "fmt" - "github.com/github/gh-osc/go/mysql" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/mysql" + "github.com/github/gh-ost/go/sql" "github.com/outbrain/golib/log" gomysql "github.com/siddontang/go-mysql/mysql" diff --git a/go/binlog/mysqlbinlog_reader.go b/go/binlog/mysqlbinlog_reader.go index 87e408a..c9c64ce 100644 --- a/go/binlog/mysqlbinlog_reader.go +++ b/go/binlog/mysqlbinlog_reader.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog @@ -14,7 +14,7 @@ import ( "strconv" // "strings" - "github.com/github/gh-osc/go/os" + "github.com/github/gh-ost/go/os" "github.com/outbrain/golib/log" ) diff --git a/go/binlog/mysqlbinlog_reader_test.go b/go/binlog/mysqlbinlog_reader_test.go index 81795bd..c2e641e 100644 --- a/go/binlog/mysqlbinlog_reader_test.go +++ b/go/binlog/mysqlbinlog_reader_test.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package binlog diff --git a/go/cmd/gh-osc/main.go b/go/cmd/gh-osc/main.go index f7413e2..01cb6f5 100644 --- a/go/cmd/gh-osc/main.go +++ b/go/cmd/gh-osc/main.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package main @@ -10,8 +10,8 @@ import ( "fmt" "os" - "github.com/github/gh-osc/go/base" - "github.com/github/gh-osc/go/logic" + "github.com/github/gh-ost/go/base" + "github.com/github/gh-ost/go/logic" "github.com/outbrain/golib/log" ) @@ -32,7 +32,7 @@ func main() { flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica") 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 tables are not swapped; gh-osc issues `STOP SLAVE` and you can compare the two tables for building trust") + flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration tables are not swapped; gh-ost issues `STOP SLAVE` and you can compare the two tables for building trust") flag.BoolVar(&migrationContext.OkToDropTable, "ok-to-drop-table", false, "Shall the tool drop the old table at end of operation. DROPping tables can be a long locking operation, which is why I'm not doing it by default. I'm an online tool, yes?") flag.BoolVar(&migrationContext.QuickAndBumpySwapTables, "quick-and-bumpy-swap-tables", false, "Shall the tool issue a faster swapping of tables at end of operation, at the cost of causing a brief period of time when the table does not exist? This will cause queries on table to fail with error (as opposed to being locked for a longer duration of a swap)") flag.BoolVar(&migrationContext.InitiallyDropOldTable, "initially-drop-old-table", false, "Drop a possibly existing OLD table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists") @@ -47,10 +47,10 @@ func main() { migrationContext.ChunkSize = 100000 } flag.Int64Var(&migrationContext.MaxLagMillisecondsThrottleThreshold, "max-lag-millis", 1500, "replication lag at which to throttle operation") - flag.StringVar(&migrationContext.ReplictionLagQuery, "replication-lag-query", "", "Query that detects replication lag in seconds. Result can be a floating point (by default gh-osc issues SHOW SLAVE STATUS and reads Seconds_behind_master). If you're using pt-heartbeat, query would be something like: SELECT ROUND(UNIX_TIMESTAMP() - MAX(UNIX_TIMESTAMP(ts))) AS delay FROM my_schema.heartbeat") + flag.StringVar(&migrationContext.ReplictionLagQuery, "replication-lag-query", "", "Query that detects replication lag in seconds. Result can be a floating point (by default gh-ost issues SHOW SLAVE STATUS and reads Seconds_behind_master). If you're using pt-heartbeat, query would be something like: SELECT ROUND(UNIX_TIMESTAMP() - MAX(UNIX_TIMESTAMP(ts))) AS delay FROM my_schema.heartbeat") throttleControlReplicas := flag.String("throttle-control-replicas", "", "List of replicas on which to check for lag; comma delimited. Example: myhost1.com:3306,myhost2.com,myhost3.com:3307") flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered") - flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-osc.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-osc operations") + flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-ost.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations") maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'") quiet := flag.Bool("quiet", false, "quiet") verbose := flag.Bool("verbose", false, "verbose") @@ -60,7 +60,7 @@ func main() { flag.Parse() if *help { - fmt.Fprintf(os.Stderr, "Usage of gh-osc:\n") + fmt.Fprintf(os.Stderr, "Usage of gh-ost:\n") flag.PrintDefaults() return } @@ -106,7 +106,7 @@ func main() { log.Fatale(err) } - log.Info("starting gh-osc") + log.Info("starting gh-ost") migrator := logic.NewMigrator() err := migrator.Migrate() diff --git a/go/logic/applier.go b/go/logic/applier.go index b34b20b..7c5cff4 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package logic @@ -11,10 +11,10 @@ import ( "sync/atomic" "time" - "github.com/github/gh-osc/go/base" - "github.com/github/gh-osc/go/binlog" - "github.com/github/gh-osc/go/mysql" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/base" + "github.com/github/gh-ost/go/binlog" + "github.com/github/gh-ost/go/mysql" + "github.com/github/gh-ost/go/sql" "github.com/outbrain/golib/log" "github.com/outbrain/golib/sqlutils" @@ -70,7 +70,7 @@ func (this *Applier) validateConnection(db *gosql.DB) error { } func (this *Applier) tableExists(tableName string) (tableFound bool) { - query := fmt.Sprintf(`show /* gh-osc */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName) + query := fmt.Sprintf(`show /* gh-ost */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName) sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error { tableFound = true @@ -102,7 +102,7 @@ func (this *Applier) ValidateOrDropExistingTables() error { // CreateGhostTable creates the ghost table on the applier host func (this *Applier) CreateGhostTable() error { - query := fmt.Sprintf(`create /* gh-osc */ table %s.%s like %s.%s`, + query := fmt.Sprintf(`create /* gh-ost */ table %s.%s like %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.GetGhostTableName()), sql.EscapeName(this.migrationContext.DatabaseName), @@ -121,7 +121,7 @@ func (this *Applier) CreateGhostTable() error { // AlterGhost applies `alter` statement on ghost table func (this *Applier) AlterGhost() error { - query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s %s`, + query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s %s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.GetGhostTableName()), this.migrationContext.AlterStatement, @@ -143,7 +143,7 @@ func (this *Applier) CreateChangelogTable() error { if err := this.DropChangelogTable(); err != nil { return err } - query := fmt.Sprintf(`create /* gh-osc */ table %s.%s ( + query := fmt.Sprintf(`create /* gh-ost */ table %s.%s ( id bigint auto_increment, last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, hint varchar(64) charset ascii not null, @@ -168,7 +168,7 @@ func (this *Applier) CreateChangelogTable() error { // dropTable drops a given table on the applied host func (this *Applier) dropTable(tableName string) error { - query := fmt.Sprintf(`drop /* gh-osc */ table if exists %s.%s`, + query := fmt.Sprintf(`drop /* gh-ost */ table if exists %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(tableName), ) @@ -211,7 +211,7 @@ func (this *Applier) WriteChangelog(hint, value string) (string, error) { explicitId = 3 } query := fmt.Sprintf(` - insert /* gh-osc */ into %s.%s + insert /* gh-ost */ into %s.%s (id, hint, value) values (NULLIF(?, 0), ?, ?) @@ -336,7 +336,7 @@ func (this *Applier) __unused_IterationIsComplete() (bool, error) { } args = append(args, explodedArgs...) query := fmt.Sprintf(` - select /* gh-osc IterationIsComplete */ 1 + select /* gh-ost IterationIsComplete */ 1 from %s.%s where (%s) and (%s) limit 1 @@ -434,7 +434,7 @@ func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected // LockTables func (this *Applier) LockTables() error { - // query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write, %s.%s write, %s.%s write`, + // query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write, %s.%s write, %s.%s write`, // sql.EscapeName(this.migrationContext.DatabaseName), // sql.EscapeName(this.migrationContext.OriginalTableName), // sql.EscapeName(this.migrationContext.DatabaseName), @@ -442,7 +442,7 @@ func (this *Applier) LockTables() error { // sql.EscapeName(this.migrationContext.DatabaseName), // sql.EscapeName(this.migrationContext.GetChangelogTableName()), // ) - query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write`, + query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName), ) @@ -457,7 +457,7 @@ func (this *Applier) LockTables() error { // UnlockTables func (this *Applier) UnlockTables() error { - query := `unlock /* gh-osc */ tables` + query := `unlock /* gh-ost */ tables` log.Infof("Unlocking tables") if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil { return err @@ -468,7 +468,7 @@ func (this *Applier) UnlockTables() error { // SwapTablesQuickAndBumpy func (this *Applier) SwapTablesQuickAndBumpy() error { - query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`, + query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName), sql.EscapeName(this.migrationContext.GetOldTableName()), @@ -478,7 +478,7 @@ func (this *Applier) SwapTablesQuickAndBumpy() error { if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil { return err } - query = fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`, + query = fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.GetGhostTableName()), sql.EscapeName(this.migrationContext.OriginalTableName), @@ -513,7 +513,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error { } sessionIdChan <- sessionId - query = fmt.Sprintf(`rename /* gh-osc */ table %s.%s to %s.%s, %s.%s to %s.%s`, + query = fmt.Sprintf(`rename /* gh-ost */ table %s.%s to %s.%s, %s.%s to %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName), sql.EscapeName(this.migrationContext.DatabaseName), @@ -539,7 +539,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error { // We need to keep the SQL thread active so as to complete processing received events, // and have them written to the binary log, so that we can then read them via streamer func (this *Applier) StopSlaveIOThread() error { - query := `stop /* gh-osc */ slave io_thread` + query := `stop /* gh-ost */ slave io_thread` log.Infof("Stopping replication") if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil { return err @@ -646,7 +646,7 @@ func (this *Applier) IssueBlockingQueryOnVoluntaryLock(sessionIdChan chan int64) // Grab query := fmt.Sprintf(` - select /* gh-osc blocking-query-%s */ + select /* gh-ost blocking-query-%s */ release_lock(?) from %s.%s where diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 8a56a57..ae6f55b 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package logic @@ -10,9 +10,9 @@ import ( "fmt" "strings" - "github.com/github/gh-osc/go/base" - "github.com/github/gh-osc/go/mysql" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/base" + "github.com/github/gh-ost/go/mysql" + "github.com/github/gh-ost/go/sql" "github.com/outbrain/golib/log" "github.com/outbrain/golib/sqlutils" @@ -142,7 +142,7 @@ func (this *Inspector) validateConnection() error { // validateGrants verifies the user by which we're executing has necessary grants // to do its thang. func (this *Inspector) validateGrants() error { - query := `show /* gh-osc */ grants for current_user()` + query := `show /* gh-ost */ grants for current_user()` foundAll := false foundSuper := false foundReplicationSlave := false @@ -242,7 +242,7 @@ func (this *Inspector) validateBinlogs() error { if !this.migrationContext.SwitchToRowBinlogFormat { return fmt.Errorf("You must be using ROW binlog format. I can switch it for you, provided --switch-to-rbr and that %s:%d doesn't have replicas", this.connectionConfig.Key.Hostname, this.connectionConfig.Key.Port) } - query := fmt.Sprintf(`show /* gh-osc */ slave hosts`) + query := fmt.Sprintf(`show /* gh-ost */ slave hosts`) countReplicas := 0 err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error { countReplicas++ @@ -268,7 +268,7 @@ func (this *Inspector) validateBinlogs() error { // validateTable makes sure the table we need to operate on actually exists func (this *Inspector) validateTable() error { - query := fmt.Sprintf(`show /* gh-osc */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), this.migrationContext.OriginalTableName) + query := fmt.Sprintf(`show /* gh-ost */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), this.migrationContext.OriginalTableName) tableFound := false err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error { @@ -325,7 +325,7 @@ func (this *Inspector) validateTableForeignKeys() error { } func (this *Inspector) estimateTableRowsViaExplain() error { - query := fmt.Sprintf(`explain select /* gh-osc */ * from %s.%s where 1=1`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) + query := fmt.Sprintf(`explain select /* gh-ost */ * from %s.%s where 1=1`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) outputFound := false err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error { @@ -347,7 +347,7 @@ func (this *Inspector) estimateTableRowsViaExplain() error { func (this *Inspector) countTableRows() error { log.Infof("As instructed, I'm issuing a SELECT COUNT(*) on the table. This may take a while") - query := fmt.Sprintf(`select /* gh-osc */ count(*) as rows from %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) + query := fmt.Sprintf(`select /* gh-ost */ count(*) as rows from %s.%s`, sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName)) if err := this.db.QueryRow(query).Scan(&this.migrationContext.RowsEstimate); err != nil { return err } diff --git a/go/logic/migrator.go b/go/logic/migrator.go index b667015..1a9484f 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package logic @@ -13,10 +13,10 @@ import ( "syscall" "time" - "github.com/github/gh-osc/go/base" - "github.com/github/gh-osc/go/binlog" - "github.com/github/gh-osc/go/mysql" - "github.com/github/gh-osc/go/sql" + "github.com/github/gh-ost/go/base" + "github.com/github/gh-ost/go/binlog" + "github.com/github/gh-ost/go/mysql" + "github.com/github/gh-ost/go/sql" "github.com/outbrain/golib/log" ) diff --git a/go/logic/streamer.go b/go/logic/streamer.go index 333c842..e855aad 100644 --- a/go/logic/streamer.go +++ b/go/logic/streamer.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package logic @@ -11,9 +11,9 @@ import ( "strings" "sync" - "github.com/github/gh-osc/go/base" - "github.com/github/gh-osc/go/binlog" - "github.com/github/gh-osc/go/mysql" + "github.com/github/gh-ost/go/base" + "github.com/github/gh-ost/go/binlog" + "github.com/github/gh-ost/go/mysql" "github.com/outbrain/golib/log" "github.com/outbrain/golib/sqlutils" @@ -137,7 +137,7 @@ func (this *EventsStreamer) validateConnection() error { // validateGrants verifies the user by which we're executing has necessary grants // to do its thang. func (this *EventsStreamer) readCurrentBinlogCoordinates() error { - query := `show /* gh-osc readCurrentBinlogCoordinates */ master status` + query := `show /* gh-ost readCurrentBinlogCoordinates */ master status` foundMasterStatus := false err := sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error { this.nextBinlogCoordinates = &mysql.BinlogCoordinates{ diff --git a/go/mysql/binlog.go b/go/mysql/binlog.go index 42cf933..d98c9e5 100644 --- a/go/mysql/binlog.go +++ b/go/mysql/binlog.go @@ -1,6 +1,6 @@ /* Copyright 2015 Shlomi Noach, courtesy Booking.com - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package mysql diff --git a/go/mysql/connection.go b/go/mysql/connection.go index 4d15241..1ba6ed9 100644 --- a/go/mysql/connection.go +++ b/go/mysql/connection.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package mysql diff --git a/go/mysql/instance_key.go b/go/mysql/instance_key.go index 06f6bd5..ca5419e 100644 --- a/go/mysql/instance_key.go +++ b/go/mysql/instance_key.go @@ -1,6 +1,6 @@ /* Copyright 2015 Shlomi Noach, courtesy Booking.com - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package mysql diff --git a/go/mysql/instance_key_map.go b/go/mysql/instance_key_map.go index 6adbd50..d0900ef 100644 --- a/go/mysql/instance_key_map.go +++ b/go/mysql/instance_key_map.go @@ -1,6 +1,6 @@ /* Copyright 2015 Shlomi Noach, courtesy Booking.com - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package mysql diff --git a/go/mysql/utils.go b/go/mysql/utils.go index 834f9d4..80ee6b0 100644 --- a/go/mysql/utils.go +++ b/go/mysql/utils.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package mysql diff --git a/go/os/process.go b/go/os/process.go index edcb62c..0d4d242 100644 --- a/go/os/process.go +++ b/go/os/process.go @@ -25,7 +25,7 @@ import ( func execCmd(commandText string, arguments ...string) (*exec.Cmd, string, error) { commandBytes := []byte(commandText) - tmpFile, err := ioutil.TempFile("", "gh-osc-process-cmd-") + tmpFile, err := ioutil.TempFile("", "gh-ost-process-cmd-") if err != nil { return nil, "", log.Errore(err) } diff --git a/go/sql/builder.go b/go/sql/builder.go index 4b73a5a..68cce1e 100644 --- a/go/sql/builder.go +++ b/go/sql/builder.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package sql @@ -188,7 +188,7 @@ func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName strin transactionalClause = "lock in share mode" } result = fmt.Sprintf(` - insert /* gh-osc %s.%s */ ignore into %s.%s (%s) + insert /* gh-ost %s.%s */ ignore into %s.%s (%s) (select %s from %s.%s force index (%s) where (%s and %s) %s ) @@ -231,7 +231,7 @@ func BuildUniqueKeyRangeEndPreparedQuery(databaseName, tableName string, uniqueK uniqueKeyColumnDescending[i] = fmt.Sprintf("%s desc", uniqueKeyColumns[i]) } result = fmt.Sprintf(` - select /* gh-osc %s.%s %s */ %s + select /* gh-ost %s.%s %s */ %s from ( select %s @@ -276,7 +276,7 @@ func buildUniqueKeyMinMaxValuesPreparedQuery(databaseName, tableName string, uni uniqueKeyColumnOrder[i] = fmt.Sprintf("%s %s", uniqueKeyColumns[i], order) } query := fmt.Sprintf(` - select /* gh-osc %s.%s */ %s + select /* gh-ost %s.%s */ %s from %s.%s order by @@ -307,7 +307,7 @@ func BuildDMLDeleteQuery(databaseName, tableName string, tableColumns, uniqueKey return result, uniqueKeyArgs, err } result = fmt.Sprintf(` - delete /* gh-osc %s.%s */ + delete /* gh-ost %s.%s */ from %s.%s where @@ -344,7 +344,7 @@ func BuildDMLInsertQuery(databaseName, tableName string, tableColumns, sharedCol preparedValues := buildPreparedValues(sharedColumns.Len()) result = fmt.Sprintf(` - replace /* gh-osc %s.%s */ into + replace /* gh-ost %s.%s */ into %s.%s (%s) values @@ -397,7 +397,7 @@ func BuildDMLUpdateQuery(databaseName, tableName string, tableColumns, sharedCol equalsComparison, err := BuildEqualsPreparedComparison(uniqueKeyColumns.Names) result = fmt.Sprintf(` - update /* gh-osc %s.%s */ + update /* gh-ost %s.%s */ %s.%s set %s diff --git a/go/sql/builder_test.go b/go/sql/builder_test.go index 3e0a8c6..2c096c8 100644 --- a/go/sql/builder_test.go +++ b/go/sql/builder_test.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package sql @@ -175,7 +175,7 @@ func TestBuildRangeInsertQuery(t *testing.T) { query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false) test.S(t).ExpectNil(err) expected := ` - insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position) + insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position) (select id, name, position from mydb.tbl force index (PRIMARY) where (((id > @v1s) or ((id = @v1s))) and ((id < @v1e) or ((id = @v1e)))) ) @@ -194,7 +194,7 @@ func TestBuildRangeInsertQuery(t *testing.T) { query, explodedArgs, err := BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartValues, rangeEndValues, rangeStartArgs, rangeEndArgs, true, false) test.S(t).ExpectNil(err) expected := ` - insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position) + insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position) (select id, name, position from mydb.tbl force index (name_position_uidx) where (((name > @v1s) or (((name = @v1s)) AND (position > @v2s)) or ((name = @v1s) and (position = @v2s))) and ((name < @v1e) or (((name = @v1e)) AND (position < @v2e)) or ((name = @v1e) and (position = @v2e)))) ) @@ -218,7 +218,7 @@ func TestBuildRangeInsertPreparedQuery(t *testing.T) { query, explodedArgs, err := BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName, sharedColumns, uniqueKey, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, true, true) test.S(t).ExpectNil(err) expected := ` - insert /* gh-osc mydb.tbl */ ignore into mydb.ghost (id, name, position) + insert /* gh-ost mydb.tbl */ ignore into mydb.ghost (id, name, position) (select id, name, position from mydb.tbl force index (name_position_uidx) where (((name > ?) or (((name = ?)) AND (position > ?)) or ((name = ?) and (position = ?))) and ((name < ?) or (((name = ?)) AND (position < ?)) or ((name = ?) and (position = ?)))) lock in share mode ) @@ -240,7 +240,7 @@ func TestBuildUniqueKeyRangeEndPreparedQuery(t *testing.T) { query, explodedArgs, err := BuildUniqueKeyRangeEndPreparedQuery(databaseName, originalTableName, uniqueKeyColumns, rangeStartArgs, rangeEndArgs, chunkSize, "test") test.S(t).ExpectNil(err) expected := ` - select /* gh-osc mydb.tbl test */ name, position + select /* gh-ost mydb.tbl test */ name, position from ( select name, position @@ -268,7 +268,7 @@ func TestBuildUniqueKeyMinValuesPreparedQuery(t *testing.T) { query, err := BuildUniqueKeyMinValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns) test.S(t).ExpectNil(err) expected := ` - select /* gh-osc mydb.tbl */ name, position + select /* gh-ost mydb.tbl */ name, position from mydb.tbl order by @@ -281,7 +281,7 @@ func TestBuildUniqueKeyMinValuesPreparedQuery(t *testing.T) { query, err := BuildUniqueKeyMaxValuesPreparedQuery(databaseName, originalTableName, uniqueKeyColumns) test.S(t).ExpectNil(err) expected := ` - select /* gh-osc mydb.tbl */ name, position + select /* gh-ost mydb.tbl */ name, position from mydb.tbl order by @@ -303,7 +303,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) { query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args) test.S(t).ExpectNil(err) expected := ` - delete /* gh-osc mydb.tbl */ + delete /* gh-ost mydb.tbl */ from mydb.tbl where @@ -318,7 +318,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) { query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args) test.S(t).ExpectNil(err) expected := ` - delete /* gh-osc mydb.tbl */ + delete /* gh-ost mydb.tbl */ from mydb.tbl where @@ -333,7 +333,7 @@ func TestBuildDMLDeleteQuery(t *testing.T) { query, uniqueKeyArgs, err := BuildDMLDeleteQuery(databaseName, tableName, tableColumns, uniqueKeyColumns, args) test.S(t).ExpectNil(err) expected := ` - delete /* gh-osc mydb.tbl */ + delete /* gh-ost mydb.tbl */ from mydb.tbl where @@ -361,7 +361,7 @@ func TestBuildDMLInsertQuery(t *testing.T) { query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args) test.S(t).ExpectNil(err) expected := ` - replace /* gh-osc mydb.tbl */ + replace /* gh-ost mydb.tbl */ into mydb.tbl (id, name, position, age) values @@ -375,7 +375,7 @@ func TestBuildDMLInsertQuery(t *testing.T) { query, sharedArgs, err := BuildDMLInsertQuery(databaseName, tableName, tableColumns, sharedColumns, args) test.S(t).ExpectNil(err) expected := ` - replace /* gh-osc mydb.tbl */ + replace /* gh-ost mydb.tbl */ into mydb.tbl (position, name, age, id) values @@ -408,7 +408,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) { query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs) test.S(t).ExpectNil(err) expected := ` - update /* gh-osc mydb.tbl */ + update /* gh-ost mydb.tbl */ mydb.tbl set id=?, name=?, position=?, age=? where @@ -424,7 +424,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) { query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs) test.S(t).ExpectNil(err) expected := ` - update /* gh-osc mydb.tbl */ + update /* gh-ost mydb.tbl */ mydb.tbl set id=?, name=?, position=?, age=? where @@ -440,7 +440,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) { query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs) test.S(t).ExpectNil(err) expected := ` - update /* gh-osc mydb.tbl */ + update /* gh-ost mydb.tbl */ mydb.tbl set id=?, name=?, position=?, age=? where @@ -456,7 +456,7 @@ func TestBuildDMLUpdateQuery(t *testing.T) { query, sharedArgs, uniqueKeyArgs, err := BuildDMLUpdateQuery(databaseName, tableName, tableColumns, sharedColumns, uniqueKeyColumns, valueArgs, whereArgs) test.S(t).ExpectNil(err) expected := ` - update /* gh-osc mydb.tbl */ + update /* gh-ost mydb.tbl */ mydb.tbl set id=?, name=?, position=?, age=? where diff --git a/go/sql/types.go b/go/sql/types.go index ea73b3a..688f87e 100644 --- a/go/sql/types.go +++ b/go/sql/types.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package sql diff --git a/go/sql/types_test.go b/go/sql/types_test.go index 177b8cf..cc0d792 100644 --- a/go/sql/types_test.go +++ b/go/sql/types_test.go @@ -1,6 +1,6 @@ /* Copyright 2016 GitHub Inc. - See https://github.com/github/gh-osc/blob/master/LICENSE + See https://github.com/github/gh-ost/blob/master/LICENSE */ package sql