Skip to content

Commit 7d3514b

Browse files
author
Shlomi Noach
authored
Merge branch 'master' into incorrect-datetime-1970
2 parents e65e0ee + 4b1b70d commit 7d3514b

Some content is hidden

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

51 files changed

+436
-66
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ os:
88

99
env:
1010
- MYSQL_USER=root
11+
- CURRENT_CI_ENV=travis
12+
13+
addons:
14+
apt:
15+
packages:
16+
- git
17+
- numactl
18+
- libaio1
1119

1220
before_install:
1321
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
1422

1523
install: true
1624

17-
script: script/cibuild
25+
script:
26+
- script/cibuild
1827

1928
notifications:
2029
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.45

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function build {
1010
GOOS=$3
1111
GOARCH=$4
1212

13-
if [[ $(go version | egrep "go1[.][012345678]") ]]; then
13+
if ! go version | egrep -q 'go(1[.]9|1[.]1[0-9])' ; then
1414
echo "go version is too low. Must use 1.9 or above"
1515
exit 1
1616
fi

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

doc/requirements-and-limitations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ The `SUPER` privilege is required for `STOP SLAVE`, `START SLAVE` operations. Th
5252
- If you have en `enum` field as part of your migration key (typically the `PRIMARY KEY`), migration performance will be degraded and potentially bad. [Read more](https://github.com/github/gh-ost/pull/277#issuecomment-254811520)
5353

5454
- Migrating a `FEDERATED` table is unsupported and is irrelevant to the problem `gh-ost` tackles.
55+
56+
- `ALTER TABLE ... RENAME TO some_other_name` is not supported (and you shouldn't use `gh-ost` for such a trivial operation).

go/base/context.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ type RowsEstimateMethod string
2828

2929
const (
3030
TableStatusRowsEstimate RowsEstimateMethod = "TableStatusRowsEstimate"
31-
ExplainRowsEstimate = "ExplainRowsEstimate"
32-
CountRowsEstimate = "CountRowsEstimate"
31+
ExplainRowsEstimate RowsEstimateMethod = "ExplainRowsEstimate"
32+
CountRowsEstimate RowsEstimateMethod = "CountRowsEstimate"
3333
)
3434

3535
type CutOver int
3636

3737
const (
38-
CutOverAtomic CutOver = iota
39-
CutOverTwoStep = iota
38+
CutOverAtomic CutOver = iota
39+
CutOverTwoStep
4040
)
4141

4242
type ThrottleReasonHint string
4343

4444
const (
4545
NoThrottleReasonHint ThrottleReasonHint = "NoThrottleReasonHint"
46-
UserCommandThrottleReasonHint = "UserCommandThrottleReasonHint"
47-
LeavingHibernationThrottleReasonHint = "LeavingHibernationThrottleReasonHint"
46+
UserCommandThrottleReasonHint ThrottleReasonHint = "UserCommandThrottleReasonHint"
47+
LeavingHibernationThrottleReasonHint ThrottleReasonHint = "LeavingHibernationThrottleReasonHint"
4848
)
4949

5050
const (
@@ -91,6 +91,7 @@ type MigrationContext struct {
9191
SkipRenamedColumns bool
9292
IsTungsten bool
9393
DiscardForeignKeys bool
94+
AliyunRDS bool
9495

9596
config ContextConfig
9697
configMutex *sync.Mutex
@@ -118,6 +119,8 @@ type MigrationContext struct {
118119
CriticalLoadHibernateSeconds int64
119120
PostponeCutOverFlagFile string
120121
CutOverLockTimeoutSeconds int64
122+
CutOverExponentialBackoff bool
123+
ExponentialBackoffMaxInterval int64
121124
ForceNamedCutOverCommand bool
122125
PanicFlagFile string
123126
HooksPath string
@@ -341,6 +344,14 @@ func (this *MigrationContext) SetCutOverLockTimeoutSeconds(timeoutSeconds int64)
341344
return nil
342345
}
343346

347+
func (this *MigrationContext) SetExponentialBackoffMaxInterval(intervalSeconds int64) error {
348+
if intervalSeconds < 2 {
349+
return fmt.Errorf("Minimal maximum interval is 2sec. Timeout remains at %d", this.ExponentialBackoffMaxInterval)
350+
}
351+
this.ExponentialBackoffMaxInterval = intervalSeconds
352+
return nil
353+
}
354+
344355
func (this *MigrationContext) SetDefaultNumRetries(retries int64) {
345356
this.throttleMutex.Lock()
346357
defer this.throttleMutex.Unlock()

go/base/utils.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,26 @@ func StringContainsAll(s string, substrings ...string) bool {
6464
return nonEmptyStringsFound
6565
}
6666

67-
func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig) (string, error) {
68-
query := `select @@global.port, @@global.version`
67+
func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, migrationContext *MigrationContext) (string, error) {
68+
versionQuery := `select @@global.version`
6969
var port, extraPort int
7070
var version string
71-
if err := db.QueryRow(query).Scan(&port, &version); err != nil {
71+
if err := db.QueryRow(versionQuery).Scan(&version); err != nil {
7272
return "", err
7373
}
7474
extraPortQuery := `select @@global.extra_port`
7575
if err := db.QueryRow(extraPortQuery).Scan(&extraPort); err != nil {
7676
// swallow this error. not all servers support extra_port
7777
}
78+
// AliyunRDS set users port to "NULL", replace it by gh-ost param
79+
if migrationContext.AliyunRDS {
80+
port = connectionConfig.Key.Port
81+
} else {
82+
portQuery := `select @@global.port`
83+
if err := db.QueryRow(portQuery).Scan(&port); err != nil {
84+
return "", err
85+
}
86+
}
7887

7988
if connectionConfig.Key.Port == port || (extraPort > 0 && connectionConfig.Key.Port == extraPort) {
8089
log.Infof("connection validated on %+v", connectionConfig.Key)

go/binlog/binlog_dml_event.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ package binlog
77

88
import (
99
"fmt"
10-
"github.com/github/gh-ost/go/sql"
1110
"strings"
11+
12+
"github.com/github/gh-ost/go/sql"
1213
)
1314

1415
type EventDML string
1516

1617
const (
1718
NotDML EventDML = "NoDML"
18-
InsertDML = "Insert"
19-
UpdateDML = "Update"
20-
DeleteDML = "Delete"
19+
InsertDML EventDML = "Insert"
20+
UpdateDML EventDML = "Update"
21+
DeleteDML EventDML = "Delete"
2122
)
2223

2324
func ToEventDML(description string) EventDML {

0 commit comments

Comments
 (0)