Skip to content

Commit c6a371e

Browse files
author
Shlomi Noach
committed
Merge pull request #34 from github/rename-gh-ost
Rename to gh-ost
2 parents 92d09db + 21f6ae9 commit c6a371e

26 files changed

+101
-101
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# gh-osc
1+
# gh-ost
22
GitHub's Online Schema Change for MySQL

build.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
#
33
#
44

5-
buildpath=/tmp/gh-osc
6-
target=gh-osc
5+
buildpath=/tmp/gh-ost
6+
target=gh-ost
77
timestamp=$(date "+%Y%m%d%H%M%S")
88
mkdir -p ${buildpath}
9-
gobuild="go build -o $buildpath/$target go/cmd/gh-osc/main.go"
9+
gobuild="go build -o $buildpath/$target go/cmd/gh-ost/main.go"
1010

1111
echo "Building OS/X binary"
1212
echo "GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild" | bash
13-
(cd $buildpath && tar cfz ./gh-osc-binary-osx-${timestamp}.tar.gz $target)
13+
(cd $buildpath && tar cfz ./gh-ost-binary-osx-${timestamp}.tar.gz $target)
1414

1515
echo "Building linux binary"
1616
echo "GO15VENDOREXPERIMENT=1 GOOS=linux GOARCH=amd64 $gobuild" | bash
17-
(cd $buildpath && tar cfz ./gh-osc-binary-linux-${timestamp}.tar.gz $target)
17+
(cd $buildpath && tar cfz ./gh-ost-binary-linux-${timestamp}.tar.gz $target)
1818

1919
echo "Binaries found in:"
20-
ls -1 $buildpath/gh-osc-binary*${timestamp}.tar.gz
20+
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz

go/base/context.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package base
@@ -13,8 +13,8 @@ import (
1313
"sync/atomic"
1414
"time"
1515

16-
"github.com/github/gh-osc/go/mysql"
17-
"github.com/github/gh-osc/go/sql"
16+
"github.com/github/gh-ost/go/mysql"
17+
"github.com/github/gh-ost/go/sql"
1818

1919
"gopkg.in/gcfg.v1"
2020
)

go/base/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package base

go/binlog/binlog_dml_event.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog
77

88
import (
99
"fmt"
10-
"github.com/github/gh-osc/go/sql"
10+
"github.com/github/gh-ost/go/sql"
1111
"strings"
1212
)
1313

go/binlog/binlog_entry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog
77

88
import (
99
"fmt"
10-
"github.com/github/gh-osc/go/mysql"
10+
"github.com/github/gh-ost/go/mysql"
1111
)
1212

1313
// BinlogEntry describes an entry in the binary log

go/binlog/binlog_reader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog

go/binlog/binlog_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog

go/binlog/gomysql_reader.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog
77

88
import (
99
"fmt"
1010

11-
"github.com/github/gh-osc/go/mysql"
12-
"github.com/github/gh-osc/go/sql"
11+
"github.com/github/gh-ost/go/mysql"
12+
"github.com/github/gh-ost/go/sql"
1313

1414
"github.com/outbrain/golib/log"
1515
gomysql "github.com/siddontang/go-mysql/mysql"

go/binlog/mysqlbinlog_reader.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog
@@ -14,7 +14,7 @@ import (
1414
"strconv"
1515
// "strings"
1616

17-
"github.com/github/gh-osc/go/os"
17+
"github.com/github/gh-ost/go/os"
1818
"github.com/outbrain/golib/log"
1919
)
2020

go/binlog/mysqlbinlog_reader_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package binlog

go/cmd/gh-osc/main.go go/cmd/gh-ost/main.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package main
@@ -10,8 +10,8 @@ import (
1010
"fmt"
1111
"os"
1212

13-
"github.com/github/gh-osc/go/base"
14-
"github.com/github/gh-osc/go/logic"
13+
"github.com/github/gh-ost/go/base"
14+
"github.com/github/gh-ost/go/logic"
1515
"github.com/outbrain/golib/log"
1616
)
1717

@@ -32,7 +32,7 @@ func main() {
3232
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
3333

3434
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
35-
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")
35+
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")
3636
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?")
3737
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)")
3838
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() {
4747
migrationContext.ChunkSize = 100000
4848
}
4949
flag.Int64Var(&migrationContext.MaxLagMillisecondsThrottleThreshold, "max-lag-millis", 1500, "replication lag at which to throttle operation")
50-
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")
50+
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")
5151
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")
5252
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")
53-
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")
53+
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")
5454
maxLoad := flag.String("max-load", "", "Comma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'")
5555
quiet := flag.Bool("quiet", false, "quiet")
5656
verbose := flag.Bool("verbose", false, "verbose")
@@ -60,7 +60,7 @@ func main() {
6060
flag.Parse()
6161

6262
if *help {
63-
fmt.Fprintf(os.Stderr, "Usage of gh-osc:\n")
63+
fmt.Fprintf(os.Stderr, "Usage of gh-ost:\n")
6464
flag.PrintDefaults()
6565
return
6666
}
@@ -106,7 +106,7 @@ func main() {
106106
log.Fatale(err)
107107
}
108108

109-
log.Info("starting gh-osc")
109+
log.Info("starting gh-ost")
110110

111111
migrator := logic.NewMigrator()
112112
err := migrator.Migrate()

go/logic/applier.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright 2016 GitHub Inc.
3-
See https://github.com/github/gh-osc/blob/master/LICENSE
3+
See https://github.com/github/gh-ost/blob/master/LICENSE
44
*/
55

66
package logic
@@ -11,10 +11,10 @@ import (
1111
"sync/atomic"
1212
"time"
1313

14-
"github.com/github/gh-osc/go/base"
15-
"github.com/github/gh-osc/go/binlog"
16-
"github.com/github/gh-osc/go/mysql"
17-
"github.com/github/gh-osc/go/sql"
14+
"github.com/github/gh-ost/go/base"
15+
"github.com/github/gh-ost/go/binlog"
16+
"github.com/github/gh-ost/go/mysql"
17+
"github.com/github/gh-ost/go/sql"
1818

1919
"github.com/outbrain/golib/log"
2020
"github.com/outbrain/golib/sqlutils"
@@ -70,7 +70,7 @@ func (this *Applier) validateConnection(db *gosql.DB) error {
7070
}
7171

7272
func (this *Applier) tableExists(tableName string) (tableFound bool) {
73-
query := fmt.Sprintf(`show /* gh-osc */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName)
73+
query := fmt.Sprintf(`show /* gh-ost */ table status from %s like '%s'`, sql.EscapeName(this.migrationContext.DatabaseName), tableName)
7474

7575
sqlutils.QueryRowsMap(this.db, query, func(m sqlutils.RowMap) error {
7676
tableFound = true
@@ -102,7 +102,7 @@ func (this *Applier) ValidateOrDropExistingTables() error {
102102

103103
// CreateGhostTable creates the ghost table on the applier host
104104
func (this *Applier) CreateGhostTable() error {
105-
query := fmt.Sprintf(`create /* gh-osc */ table %s.%s like %s.%s`,
105+
query := fmt.Sprintf(`create /* gh-ost */ table %s.%s like %s.%s`,
106106
sql.EscapeName(this.migrationContext.DatabaseName),
107107
sql.EscapeName(this.migrationContext.GetGhostTableName()),
108108
sql.EscapeName(this.migrationContext.DatabaseName),
@@ -121,7 +121,7 @@ func (this *Applier) CreateGhostTable() error {
121121

122122
// AlterGhost applies `alter` statement on ghost table
123123
func (this *Applier) AlterGhost() error {
124-
query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s %s`,
124+
query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s %s`,
125125
sql.EscapeName(this.migrationContext.DatabaseName),
126126
sql.EscapeName(this.migrationContext.GetGhostTableName()),
127127
this.migrationContext.AlterStatement,
@@ -143,7 +143,7 @@ func (this *Applier) CreateChangelogTable() error {
143143
if err := this.DropChangelogTable(); err != nil {
144144
return err
145145
}
146-
query := fmt.Sprintf(`create /* gh-osc */ table %s.%s (
146+
query := fmt.Sprintf(`create /* gh-ost */ table %s.%s (
147147
id bigint auto_increment,
148148
last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
149149
hint varchar(64) charset ascii not null,
@@ -168,7 +168,7 @@ func (this *Applier) CreateChangelogTable() error {
168168

169169
// dropTable drops a given table on the applied host
170170
func (this *Applier) dropTable(tableName string) error {
171-
query := fmt.Sprintf(`drop /* gh-osc */ table if exists %s.%s`,
171+
query := fmt.Sprintf(`drop /* gh-ost */ table if exists %s.%s`,
172172
sql.EscapeName(this.migrationContext.DatabaseName),
173173
sql.EscapeName(tableName),
174174
)
@@ -211,7 +211,7 @@ func (this *Applier) WriteChangelog(hint, value string) (string, error) {
211211
explicitId = 3
212212
}
213213
query := fmt.Sprintf(`
214-
insert /* gh-osc */ into %s.%s
214+
insert /* gh-ost */ into %s.%s
215215
(id, hint, value)
216216
values
217217
(NULLIF(?, 0), ?, ?)
@@ -336,7 +336,7 @@ func (this *Applier) __unused_IterationIsComplete() (bool, error) {
336336
}
337337
args = append(args, explodedArgs...)
338338
query := fmt.Sprintf(`
339-
select /* gh-osc IterationIsComplete */ 1
339+
select /* gh-ost IterationIsComplete */ 1
340340
from %s.%s
341341
where (%s) and (%s)
342342
limit 1
@@ -434,15 +434,15 @@ func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected
434434

435435
// LockTables
436436
func (this *Applier) LockTables() error {
437-
// query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write, %s.%s write, %s.%s write`,
437+
// query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write, %s.%s write, %s.%s write`,
438438
// sql.EscapeName(this.migrationContext.DatabaseName),
439439
// sql.EscapeName(this.migrationContext.OriginalTableName),
440440
// sql.EscapeName(this.migrationContext.DatabaseName),
441441
// sql.EscapeName(this.migrationContext.GetGhostTableName()),
442442
// sql.EscapeName(this.migrationContext.DatabaseName),
443443
// sql.EscapeName(this.migrationContext.GetChangelogTableName()),
444444
// )
445-
query := fmt.Sprintf(`lock /* gh-osc */ tables %s.%s write`,
445+
query := fmt.Sprintf(`lock /* gh-ost */ tables %s.%s write`,
446446
sql.EscapeName(this.migrationContext.DatabaseName),
447447
sql.EscapeName(this.migrationContext.OriginalTableName),
448448
)
@@ -457,7 +457,7 @@ func (this *Applier) LockTables() error {
457457

458458
// UnlockTables
459459
func (this *Applier) UnlockTables() error {
460-
query := `unlock /* gh-osc */ tables`
460+
query := `unlock /* gh-ost */ tables`
461461
log.Infof("Unlocking tables")
462462
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
463463
return err
@@ -468,7 +468,7 @@ func (this *Applier) UnlockTables() error {
468468

469469
// SwapTablesQuickAndBumpy
470470
func (this *Applier) SwapTablesQuickAndBumpy() error {
471-
query := fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`,
471+
query := fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`,
472472
sql.EscapeName(this.migrationContext.DatabaseName),
473473
sql.EscapeName(this.migrationContext.OriginalTableName),
474474
sql.EscapeName(this.migrationContext.GetOldTableName()),
@@ -478,7 +478,7 @@ func (this *Applier) SwapTablesQuickAndBumpy() error {
478478
if _, err := sqlutils.ExecNoPrepare(this.singletonDB, query); err != nil {
479479
return err
480480
}
481-
query = fmt.Sprintf(`alter /* gh-osc */ table %s.%s rename %s`,
481+
query = fmt.Sprintf(`alter /* gh-ost */ table %s.%s rename %s`,
482482
sql.EscapeName(this.migrationContext.DatabaseName),
483483
sql.EscapeName(this.migrationContext.GetGhostTableName()),
484484
sql.EscapeName(this.migrationContext.OriginalTableName),
@@ -513,7 +513,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error {
513513
}
514514
sessionIdChan <- sessionId
515515

516-
query = fmt.Sprintf(`rename /* gh-osc */ table %s.%s to %s.%s, %s.%s to %s.%s`,
516+
query = fmt.Sprintf(`rename /* gh-ost */ table %s.%s to %s.%s, %s.%s to %s.%s`,
517517
sql.EscapeName(this.migrationContext.DatabaseName),
518518
sql.EscapeName(this.migrationContext.OriginalTableName),
519519
sql.EscapeName(this.migrationContext.DatabaseName),
@@ -539,7 +539,7 @@ func (this *Applier) SwapTablesAtomic(sessionIdChan chan int64) error {
539539
// We need to keep the SQL thread active so as to complete processing received events,
540540
// and have them written to the binary log, so that we can then read them via streamer
541541
func (this *Applier) StopSlaveIOThread() error {
542-
query := `stop /* gh-osc */ slave io_thread`
542+
query := `stop /* gh-ost */ slave io_thread`
543543
log.Infof("Stopping replication")
544544
if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil {
545545
return err
@@ -646,7 +646,7 @@ func (this *Applier) IssueBlockingQueryOnVoluntaryLock(sessionIdChan chan int64)
646646

647647
// Grab
648648
query := fmt.Sprintf(`
649-
select /* gh-osc blocking-query-%s */
649+
select /* gh-ost blocking-query-%s */
650650
release_lock(?)
651651
from %s.%s
652652
where

0 commit comments

Comments
 (0)