Skip to content

Commit c37ea5d

Browse files
author
Shlomi Noach
authored
Merge branch 'master' into tests-updates
2 parents 0fd4603 + 79ddcec commit c37ea5d

File tree

268 files changed

+14190
-4531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+14190
-4531
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Related issue: https://github.com/github/gh-ost/issues/0123456789
1111
1212
### Description
1313

14-
This PR [briefly explain what is does]
14+
This PR [briefly explain what it does]
1515

1616
> In case this PR introduced Go code changes:
1717

.travis.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
# http://docs.travis-ci.com/user/languages/go/
22
language: go
33

4-
go: 1.8
4+
go:
5+
- "1.9"
6+
- "1.10"
57

68
os:
79
- linux
810

911
env:
1012
- MYSQL_USER=root
13+
- CURRENT_CI_ENV=travis
14+
15+
addons:
16+
apt:
17+
packages:
18+
- git
19+
- numactl
20+
- libaio1
1121

1222
before_install:
1323
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
1424

1525
install: true
1626

17-
script: script/cibuild
27+
script:
28+
- script/cibuild
1829

1930
notifications:
2031
email: false

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Please see [Coding gh-ost](doc/coding-ghost.md) for a guide to getting started d
9494

9595
[Download latest release here](https://github.com/github/gh-ost/releases/latest)
9696

97-
`gh-ost` is a Go project; it is built with Go `1.8` (though `1.7` should work as well). To build on your own, use either:
97+
`gh-ost` is a Go project; it is built with Go `1.9` and above. To build on your own, use either:
9898
- [script/build](https://github.com/github/gh-ost/blob/master/script/build) - this is the same build script used by CI hence the authoritative; artifact is `./bin/gh-ost` binary.
9999
- [build.sh](https://github.com/github/gh-ost/blob/master/build.sh) for building `tar.gz` artifacts in `/tmp/gh-ost`
100100

@@ -107,3 +107,5 @@ Generally speaking, `master` branch is stable, but only [releases](https://githu
107107
- [@ggunson](https://github.com/ggunson)
108108
- [@tomkrouper](https://github.com/tomkrouper)
109109
- [@shlomi-noach](https://github.com/shlomi-noach)
110+
- [@jessbreckenridge](https://github.com/jessbreckenridge)
111+
- [@gtowey](https://github.com/gtowey)

RELEASE_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.42
1+
1.0.47

build.sh

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,72 @@
22
#
33
#
44

5-
RELEASE_VERSION=$(cat RELEASE_VERSION)
5+
RELEASE_VERSION=
6+
buildpath=
7+
8+
function setuptree() {
9+
b=$( mktemp -d $buildpath/gh-ostXXXXXX ) || return 1
10+
mkdir -p $b/gh-ost
11+
mkdir -p $b/gh-ost/usr/bin
12+
echo $b
13+
}
614

715
function build {
8-
osname=$1
9-
osshort=$2
10-
GOOS=$3
11-
GOARCH=$4
12-
13-
echo "Building ${osname} binary"
14-
export GOOS
15-
export GOARCH
16-
go build -ldflags "$ldflags" -o $buildpath/$target go/cmd/gh-ost/main.go
17-
18-
if [ $? -ne 0 ]; then
19-
echo "Build failed for ${osname}"
20-
exit 1
21-
fi
22-
23-
(cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target)
16+
osname=$1
17+
osshort=$2
18+
GOOS=$3
19+
GOARCH=$4
20+
21+
22+
23+
if ! go version | egrep -q 'go(1[.]9|1[.]1[0-9])' ; then
24+
echo "go version is too low. Must use 1.9 or above"
25+
exit 1
26+
fi
27+
28+
echo "Building ${osname} binary"
29+
export GOOS
30+
export GOARCH
31+
go build -ldflags "$ldflags" -o $buildpath/$target go/cmd/gh-ost/main.go
32+
33+
if [ $? -ne 0 ]; then
34+
echo "Build failed for ${osname}"
35+
exit 1
36+
fi
37+
38+
(cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target)
39+
40+
if [ "$GOOS" == "linux" ] ; then
41+
echo "Creating Distro full packages"
42+
builddir=$(setuptree)
43+
cp $buildpath/$target $builddir/gh-ost/usr/bin
44+
cd $buildpath
45+
fpm -v "${RELEASE_VERSION}" --epoch 1 -f -s dir -n gh-ost -m shlomi-noach --description "GitHub's Online Schema Migrations for MySQL " --url "https://github.com/github/gh-ost" --vendor "GitHub" --license "Apache 2.0" -C $builddir/gh-ost --prefix=/ -t rpm .
46+
fpm -v "${RELEASE_VERSION}" --epoch 1 -f -s dir -n gh-ost -m shlomi-noach --description "GitHub's Online Schema Migrations for MySQL " --url "https://github.com/github/gh-ost" --vendor "GitHub" --license "Apache 2.0" -C $builddir/gh-ost --prefix=/ -t deb --deb-no-default-config-files .
47+
fi
2448
}
2549

26-
buildpath=/tmp/gh-ost
27-
target=gh-ost
28-
timestamp=$(date "+%Y%m%d%H%M%S")
29-
ldflags="-X main.AppVersion=${RELEASE_VERSION}"
30-
export GO15VENDOREXPERIMENT=1
50+
main() {
51+
if [ -z "${RELEASE_VERSION}" ] ; then
52+
RELEASE_VERSION=$(git describe --abbrev=0 --tags | tr -d 'v')
53+
fi
54+
if [ -z "${RELEASE_VERSION}" ] ; then
55+
RELEASE_VERSION=$(cat RELEASE_VERSION)
56+
fi
57+
3158

32-
mkdir -p ${buildpath}
33-
build macOS osx darwin amd64
34-
build GNU/Linux linux linux amd64
59+
buildpath=/tmp/gh-ost-release
60+
target=gh-ost
61+
timestamp=$(date "+%Y%m%d%H%M%S")
62+
ldflags="-X main.AppVersion=${RELEASE_VERSION}"
63+
64+
mkdir -p ${buildpath}
65+
rm -rf ${buildpath:?}/*
66+
build macOS osx darwin amd64
67+
build GNU/Linux linux linux amd64
68+
69+
echo "Binaries found in:"
70+
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz
71+
}
3572

36-
echo "Binaries found in:"
37-
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz
73+
main "$@"

doc/command-line-flags.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A more in-depth discussion of various `gh-ost` command line flags: implementation, implication, use cases.
44

5+
### aliyun-rds
6+
7+
Add this flag when executing on Aliyun RDS.
8+
59
### allow-master-master
610

711
See [`--assume-master-host`](#assume-master-host).
@@ -65,6 +69,10 @@ This is somewhat similar to a Nagios `n`-times test, where `n` in our case is al
6569

6670
Optional. Default is `safe`. See more discussion in [`cut-over`](cut-over.md)
6771

72+
### cut-over-lock-timeout-seconds
73+
74+
Default `3`. Max number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout).
75+
6876
### discard-foreign-keys
6977

7078
**Danger**: this flag will _silently_ discard any foreign keys existing on your table.
@@ -82,7 +90,7 @@ The `--dml-batch-size` flag controls the size of the batched write. Allowed valu
8290

8391
Why is this behavior configurable? Different workloads have different characteristics. Some workloads have very large writes, such that aggregating even `50` writes into a transaction makes for a significant transaction size. On other workloads write rate is high such that one just can't allow for a hundred more syncs to disk per second. The default value of `10` is a modest compromise that should probably work very well for most workloads. Your mileage may vary.
8492

85-
Noteworthy is that setting `--dml-batch-size` to higher value _does not_ mean `gh-ost` blocks or waits on writes. The batch size is an upper limit on transaction size, not a minimal one. If `gh-ost` doesn't have "enough" events in the pipe, it does not wait on the binary log, it just writes what it already has. This conveniently suggests that if write load is light enough for `gh-ost` to only see a few events in the binary log at a given time, then it is also light neough for `gh-ost` to apply a fraction of the batch size.
93+
Noteworthy is that setting `--dml-batch-size` to higher value _does not_ mean `gh-ost` blocks or waits on writes. The batch size is an upper limit on transaction size, not a minimal one. If `gh-ost` doesn't have "enough" events in the pipe, it does not wait on the binary log, it just writes what it already has. This conveniently suggests that if write load is light enough for `gh-ost` to only see a few events in the binary log at a given time, then it is also light enough for `gh-ost` to apply a fraction of the batch size.
8694

8795
### exact-rowcount
8896

@@ -103,6 +111,14 @@ While the ongoing estimated number of rows is still heuristic, it's almost exact
103111

104112
Without this parameter, migration is a _noop_: testing table creation and validity of migration, but not touching data.
105113

114+
### force-table-names
115+
116+
Table name prefix to be used on the temporary tables.
117+
118+
### gcp
119+
120+
Add this flag when executing on a 1st generation Google Cloud Platform (GCP).
121+
106122
### heartbeat-interval-millis
107123

108124
Default 100. See [`subsecond-lag`](subsecond-lag.md) for details.
@@ -117,6 +133,10 @@ We think `gh-ost` should not take chances or make assumptions about the user's t
117133

118134
See [`initially-drop-ghost-table`](#initially-drop-ghost-table)
119135

136+
### initially-drop-socket-file
137+
138+
Default False. Should `gh-ost` forcibly delete an existing socket file. Be careful: this might drop the socket file of a running migration!
139+
120140
### max-lag-millis
121141

122142
On a replication topology, this is perhaps the most important migration throttling factor: the maximum lag allowed for migration to work. If lag exceeds this value, migration throttles.
@@ -151,7 +171,7 @@ See also: [`concurrent-migrations`](cheatsheet.md#concurrent-migrations) on the
151171

152172
### skip-foreign-key-checks
153173

154-
By default `gh-ost` verifies no foreign keys exist on the migrated table. On servers with large number of tables this check can take a long time. If you're absolutely certain no foreign keys exist (table does not referenece other table nor is referenced by other tables) and wish to save the check time, provide with `--skip-foreign-key-checks`.
174+
By default `gh-ost` verifies no foreign keys exist on the migrated table. On servers with large number of tables this check can take a long time. If you're absolutely certain no foreign keys exist (table does not reference other table nor is referenced by other tables) and wish to save the check time, provide with `--skip-foreign-key-checks`.
155175

156176
### skip-renamed-columns
157177

@@ -161,6 +181,10 @@ See [`approve-renamed-columns`](#approve-renamed-columns)
161181

162182
Issue the migration on a replica; do not modify data on master. Useful for validating, testing and benchmarking. See [`testing-on-replica`](testing-on-replica.md)
163183

184+
### test-on-replica-skip-replica-stop
185+
186+
Default `False`. When `--test-on-replica` is enabled, do not issue commands stop replication (requires `--test-on-replica`).
187+
164188
### throttle-control-replicas
165189

166190
Provide a command delimited list of replicas; `gh-ost` will throttle when any of the given replicas lag beyond [`--max-lag-millis`](#max-lag-millis). The list can be queried and updated dynamically via [interactive commands](interactive-commands.md)

doc/hooks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ The following variables are available on all hooks:
6969
- `GH_OST_INSPECTED_HOST`
7070
- `GH_OST_EXECUTING_HOST`
7171
- `GH_OST_HOOKS_HINT` - copy of `--hooks-hint` value
72+
- `GH_OST_DRY_RUN` - whether or not the `gh-ost` run is a dry run
7273

7374
The following variable are available on particular hooks:
7475

doc/interactive-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Both interfaces may serve at the same time. Both respond to simple text command,
4343

4444
### Querying for data
4545

46-
For commands that accept an argumetn as value, pass `?` (question mark) to _get_ current value rather than _set_ a new one.
46+
For commands that accept an argument as value, pass `?` (question mark) to _get_ current value rather than _set_ a new one.
4747

4848
### Examples
4949

doc/questions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ It is therefore unlikely that `gh-ost` will support this behavior.
2828
Yes. TL;DR if running all on same replica/master, make sure to provide `--replica-server-id`. [Read more](cheatsheet.md#concurrent-migrations)
2929

3030
# Why
31+
32+
### Why Is the "Connect to Replica" mode preferred?
33+
34+
To avoid placing extra load on the master. `gh-ost` connects as a replication client. Each additional replica adds some load to the master.
35+
36+
To monitor replication lag from a replica. This makes the replication lag throttle, `--max-lag-millis`, more representative of the lag experienced by other replicas following the master (perhaps N levels deep in a tree of replicas).

doc/rds.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
`gh-ost` has been updated to work with Amazon RDS however due to GitHub not relying using AWS for databases, this documentation is community driven so if you find a bug please [open an issue][new_issue]!
1+
`gh-ost` has been updated to work with Amazon RDS however due to GitHub not using AWS for databases, this documentation is community driven so if you find a bug please [open an issue][new_issue]!
22

33
# Amazon RDS
44

0 commit comments

Comments
 (0)