Skip to content

Commit 6dbf5c3

Browse files
author
Shlomi Noach
committed
resolved conflict
2 parents ef59a86 + a75912d commit 6dbf5c3

File tree

12 files changed

+100
-25
lines changed

12 files changed

+100
-25
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
> This is the place to report a bug, ask a question, suggest an enhancment.
2+
3+
> This is the place to make a discussion before creating a PR.
4+
5+
> Please label your Issue
6+
7+
> Please understand if this Issue is not addressed immediately or in a timeframe you were expecting.
8+
9+
> Thank you!

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## A Pull Request should be associated with an Issue.
2+
3+
> We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
4+
> If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
5+
> and potentially we'll be able to point development in a particular direction.
6+
7+
Related issue: https://github.com/github/gh-ost/issues/0123456789
8+
9+
> Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
10+
11+
### Description
12+
13+
This PR [briefly explain what is does]
14+
15+
> In case this PR introduced Go code changes:
16+
17+
- [ ] contributed code is using same conventions as original code
18+
- [ ] code is formatted via `gofmt` (please avoid `goimports`)
19+
- [ ] code is built via `bash build.sh`

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# gh-ost
22

3-
#### GitHub's online schema migration for MySQL
3+
#### GitHub's online schema migration for MySQL <img src="doc/images/gh-ost-logo-light-160.png" align="right">
44

5-
`gh-ost` is a triggerless online schema migration solution for MySQL. It is testable and provides with pausability, dynamic control/reconfiguration, auditing, and many operational perks.
5+
`gh-ost` is a triggerless online schema migration solution for MySQL. It is testable and provides pausability, dynamic control/reconfiguration, auditing, and many operational perks.
66

77
`gh-ost` produces a light workload on the master throughout the migration, decoupled from the existing workload on the migrated table.
88

99
It has been designed based on years of experience with existing solutions, and changes the paradigm of table migrations.
1010

11-
![gh-ost logo](doc/images/gh-ost-logo-light-160.png)
11+
1212

1313
## How?
1414

@@ -44,7 +44,7 @@ The [cheatsheet](doc/cheatsheet.md) has it all. You may be interested in invokin
4444

4545
Our tips:
4646

47-
- [Testing above all](testing-on-replica.md), try out `--test-on-replica` first few times. Better yet, make it continuous. We have multiple replicas where we iterate our entire fleet of production tables, migrating them one by one, checksumming the results, verifying migration is good.
47+
- [Testing above all](doc/testing-on-replica.md), try out `--test-on-replica` first few times. Better yet, make it continuous. We have multiple replicas where we iterate our entire fleet of production tables, migrating them one by one, checksumming the results, verifying migration is good.
4848
- For each master migration, first issue a _noop_
4949
- Then issue the real thing via `--execute`.
5050

@@ -63,19 +63,29 @@ Originally this was named `gh-osc`: GitHub Online Schema Change, in the likes of
6363
But then a rare genetic mutation happened, and the `s` transformed into `t`. And that sent us down the path of trying to figure out a new acronym. Right now, `gh-ost` (pronounce: _Ghost_), stands for:
6464
- GitHub Online Schema Transmogrifier/Translator/Transformer/Transfigurator
6565

66-
Pronounce: _ghost_
67-
6866
## License
6967

70-
`gh-ost` is licensed under the [MIT license](https://github.com/github/gh-ost/blob/documentation/LICENSE)
68+
`gh-ost` is licensed under the [MIT license](https://github.com/github/gh-ost/blob/master/LICENSE)
7169

7270
`gh-ost` uses 3rd party libraries, each with their own license. These are found [here](https://github.com/github/gh-ost/tree/master/vendor).
7371

7472
## Community
7573

7674
`gh-ost` is released at a stable state, but with mileage to go. We are [open to pull requests](https://github.com/github/gh-ost/blob/master/.github/CONTRIBUTING.md). Please first discuss your intentions via [Issues](https://github.com/github/gh-ost/issues).
7775

78-
We develop `gh-ost` at GitHub and for the community. We may have different priorities than others. From time to time we may suggest a contribution that is not on our immediate roadmap but which may appeal to others.
76+
We develop `gh-ost` at GitHub and for the community. We may have different priorities than others. From time to time we may suggest a contribution that is not on our immediate roadmap but which may appeal to others.
77+
78+
## Download/binaries/source
79+
80+
`gh-ost` is now GA and stable.
81+
82+
`gh-ost` is available in binary format for Linux and Mac OS/X
83+
84+
[Download latest release here](https://github.com/github/gh-ost/releases/latest)
85+
86+
`gh-ost` is a Go project; it is built with Go 1.5 with "experimental vendor". Soon to migrate to Go 1.6. See and use [build file](https://github.com/github/gh-ost/blob/master/build.sh) for compiling it on your own.
87+
88+
Generally speaking, `master` branch is stable, but only [releases](https://github.com/github/gh-ost/releases) are to be used in production.
7989

8090
## Authors
8191

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
#
4-
RELEASE_VERSION="1.0.3"
4+
RELEASE_VERSION="1.0.5"
55

66
buildpath=/tmp/gh-ost
77
target=gh-ost

doc/interactive-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ replication lag on to determine throttling
2424
- `critical-load=<load>`: change critical load setting (exceeding given thresholds causes panic and abort)
2525
- `nice-ratio=<ratio>`: change _nice_ ratio: 0 for aggressive, positive integer `n`: for any unit of time spent copying rows, spend `n` units of time sleeping.
2626
- `throttle-query`: change throttle query
27-
- `throttle-control-replicas`: change list of throttle-control replicas, these are replicas `gh-ost` will cehck
27+
- `throttle-control-replicas`: change list of throttle-control replicas, these are replicas `gh-ost` will check
2828
- `throttle`: force migration suspend
2929
- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply)
3030
- `unpostpone`: at a time where `gh-ost` is postponing the [cut-over](cut-over.md) phase, instruct `gh-ost` to stop postponing and proceed immediately to cut-over.

doc/what-if.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,13 @@ There is a `lock_wait_timeout` explicitly associated with the cut-over operation
3030
This is where `gh-ost` shines. There is no need to kill it as you may be used to with other tools. You can reconfigure `gh-ost` [on the fly](https://github.com/github/gh-ost/blob/master/doc/interactive-commands.md) to be nicer.
3131

3232
You're always able to actively begin [throttling](throttle.md). Just touch the `throttle-file` or `echo throttle` into `gh-ost`. Otherwise, reconfigure your `max-load`, the `nice-ratio`, the `throttle-query` to gain better thresholds that would suit your needs.
33+
34+
### What if my replicas don't use binary logs?
35+
36+
If the master is running Row Based Replication (RBR) - point `gh-ost` to the master, and specify `--allow-on-master`. See [cheatsheets](cheatsheets.md)
37+
38+
If the master is running Statement Based Replication (SBR) - you have no alternative but to reconfigure a replica with:
39+
40+
- `log_bin`
41+
- `log_slave_updates`
42+
- `binlog_format=ROW`

go/base/context.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package base
77

88
import (
99
"fmt"
10+
"os"
11+
"regexp"
1012
"strings"
1113
"sync"
1214
"sync/atomic"
@@ -34,6 +36,10 @@ const (
3436
CutOverTwoStep = iota
3537
)
3638

39+
var (
40+
envVariableRegexp = regexp.MustCompile("[$][{](.*)[}]")
41+
)
42+
3743
// MigrationContext has the general, global state of migration. It is used by
3844
// all components throughout the migration process.
3945
type MigrationContext struct {
@@ -71,6 +77,7 @@ type MigrationContext struct {
7177
CutOverLockTimeoutSeconds int64
7278
PanicFlagFile string
7379

80+
DropServeSocket bool
7481
ServeSocketFile string
7582
ServeTCPPort int64
7683

@@ -439,8 +446,19 @@ func (this *MigrationContext) ReadConfigFile() error {
439446
if this.ConfigFile == "" {
440447
return nil
441448
}
449+
gcfg.RelaxedParserMode = true
442450
if err := gcfg.ReadFileInto(&this.config, this.ConfigFile); err != nil {
443451
return err
444452
}
453+
454+
// We accept user & password in the form "${SOME_ENV_VARIABLE}" in which case we pull
455+
// the given variable from os env
456+
if submatch := envVariableRegexp.FindStringSubmatch(this.config.Client.User); len(submatch) > 1 {
457+
this.config.Client.User = os.Getenv(submatch[1])
458+
}
459+
if submatch := envVariableRegexp.FindStringSubmatch(this.config.Client.Password); len(submatch) > 1 {
460+
this.config.Client.Password = os.Getenv(submatch[1])
461+
}
462+
445463
return nil
446464
}

go/binlog/gomysql_reader.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ func (this *GoMySQLReader) ConnectBinlogStreamer(coordinates mysql.BinlogCoordin
6363
return err
6464
}
6565

66-
func (this *GoMySQLReader) Reconnect() error {
67-
this.binlogSyncer.Close()
68-
connectCoordinates := &mysql.BinlogCoordinates{LogFile: this.currentCoordinates.LogFile, LogPos: 4}
69-
if err := this.ConnectBinlogStreamer(*connectCoordinates); err != nil {
70-
return err
71-
}
72-
return nil
73-
}
74-
7566
func (this *GoMySQLReader) GetCurrentBinlogCoordinates() *mysql.BinlogCoordinates {
7667
this.currentCoordinatesMutex.Lock()
7768
defer this.currentCoordinatesMutex.Unlock()

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func main() {
8383
flag.StringVar(&migrationContext.PostponeCutOverFlagFile, "postpone-cut-over-flag-file", "", "while this file exists, migration will postpone the final stage of swapping tables, and will keep on syncing the ghost table. Cut-over/swapping would be ready to perform the moment the file is deleted.")
8484
flag.StringVar(&migrationContext.PanicFlagFile, "panic-flag-file", "", "when this file is created, gh-ost will immediately terminate, without cleanup")
8585

86+
flag.BoolVar(&migrationContext.DropServeSocket, "initially-drop-socket-file", false, "Should gh-ost forcibly delete an existing socket file. Be careful: this might drop the socket file of a running migration!")
8687
flag.StringVar(&migrationContext.ServeSocketFile, "serve-socket-file", "", "Unix socket file to serve on. Default: auto-determined and advertised upon startup")
8788
flag.Int64Var(&migrationContext.ServeTCPPort, "serve-tcp-port", 0, "TCP port to serve on. Default: disabled")
8889

go/logic/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (this *Server) BindSocketFile() (err error) {
3636
if this.migrationContext.ServeSocketFile == "" {
3737
return nil
3838
}
39-
if base.FileExists(this.migrationContext.ServeSocketFile) {
39+
if this.migrationContext.DropServeSocket && base.FileExists(this.migrationContext.ServeSocketFile) {
4040
os.Remove(this.migrationContext.ServeSocketFile)
4141
}
4242
this.unixListener, err = net.Listen("unix", this.migrationContext.ServeSocketFile)

0 commit comments

Comments
 (0)