Skip to content

Commit b02900a

Browse files
author
Justin Fudally
authored
Merge branch 'master' into logging-interface-contrib
2 parents 6b6f9ec + 4dab06e commit b02900a

File tree

16 files changed

+187
-43
lines changed

16 files changed

+187
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/bin/
33
/libexec/
44
/.vendor/
5+
.idea/

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Dockerfile.packaging

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
3+
FROM golang:1.12.6
4+
5+
RUN apt-get update
6+
RUN apt-get install -y ruby ruby-dev rubygems build-essential
7+
RUN gem install --no-ri --no-rdoc fpm
8+
ENV GOPATH=/tmp/go
9+
10+
RUN apt-get install -y curl
11+
RUN apt-get install -y rsync
12+
RUN apt-get install -y gcc
13+
RUN apt-get install -y g++
14+
RUN apt-get install -y bash
15+
RUN apt-get install -y git
16+
RUN apt-get install -y tar
17+
RUN apt-get install -y rpm
18+
19+
RUN mkdir -p $GOPATH/src/github.com/github/gh-ost
20+
WORKDIR $GOPATH/src/github.com/github/gh-ost
21+
COPY . .
22+
RUN bash build.sh

RELEASE_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.48
1+
1.0.49

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ main() {
6161

6262
mkdir -p ${buildpath}
6363
rm -rf ${buildpath:?}/*
64-
build macOS osx darwin amd64
6564
build GNU/Linux linux linux amd64
65+
# build macOS osx darwin amd64
6666

6767
echo "Binaries found in:"
68-
ls -1 $buildpath/gh-ost-binary*${timestamp}.tar.gz
68+
find $buildpath/gh-ost* -type f -maxdepth 1
6969
}
7070

7171
main "$@"

doc/rds.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ If you use `pt-table-checksum` as a part of your data integrity checks, you migh
2626
This tool requires binlog_format=STATEMENT, but the current binlog_format is set to ROW and an error occurred while attempting to change it. If running MySQL 5.1.29 or newer, setting binlog_format requires the SUPER privilege. You will need to manually set binlog_format to 'STATEMENT' before running this tool.
2727
```
2828

29+
#### Binlog filtering
30+
31+
In Aurora, the [binlog filtering feature][aws_replication_docs_bin_log_filtering] is enabled by default. This becomes an issue when gh-ost tries to do the cut-over, because gh-ost waits for an entry in the binlog to proceed but this entry will never end up in the binlog because it gets filtered out by the binlog filtering feature.
32+
You need to turn this feature off during the migration process.
33+
Set the `aurora_enable_repl_bin_log_filtering` parameter to 0 in the Parameter Group for your cluster.
34+
When the migration is done, set it back to 1 (default).
35+
36+
2937
#### Preflight checklist
3038

3139
Before trying to run any `gh-ost` migrations you will want to confirm the following:
@@ -35,6 +43,7 @@ Before trying to run any `gh-ost` migrations you will want to confirm the follow
3543
- [ ] Executing `SHOW SLAVE STATUS\G` on your replica cluster displays the correct master host, binlog position, etc.
3644
- [ ] Database backup retention is greater than 1 day to enable binlogs
3745
- [ ] You have setup [`hooks`][ghost_hooks] to issue RDS procedures for stopping and starting replication. (see [github/gh-ost#163][ghost_rds_issue_tracking] for examples)
46+
- [ ] The parameter `aurora_enable_repl_bin_log_filtering` is set to 0
3847

3948
[new_issue]: https://github.com/github/gh-ost/issues/new
4049
[assume_rbr_docs]: https://github.com/github/gh-ost/blob/master/doc/command-line-flags.md#assume-rbr
@@ -43,3 +52,4 @@ Before trying to run any `gh-ost` migrations you will want to confirm the follow
4352
[percona_toolkit_patch]: https://github.com/jacobbednarz/percona-toolkit/commit/0271ba6a094da446a5e5bb8d99b5c26f1777f2b9
4453
[ghost_hooks]: https://github.com/github/gh-ost/blob/master/doc/hooks.md
4554
[ghost_rds_issue_tracking]: https://github.com/github/gh-ost/issues/163
55+
[aws_replication_docs_bin_log_filtering]: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Replication.html#AuroraMySQL.Replication.Performance

go/base/context.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ type MigrationContext struct {
120120
ThrottleAdditionalFlagFile string
121121
throttleQuery string
122122
throttleHTTP string
123+
IgnoreHTTPErrors bool
123124
ThrottleCommandedByUser int64
124125
HibernateUntil int64
125126
maxLoad LoadMap
@@ -595,6 +596,13 @@ func (this *MigrationContext) SetThrottleHTTP(throttleHTTP string) {
595596
this.throttleHTTP = throttleHTTP
596597
}
597598

599+
func (this *MigrationContext) SetIgnoreHTTPErrors(ignoreHTTPErrors bool) {
600+
this.throttleHTTPMutex.Lock()
601+
defer this.throttleHTTPMutex.Unlock()
602+
603+
this.IgnoreHTTPErrors = ignoreHTTPErrors
604+
}
605+
598606
func (this *MigrationContext) GetMaxLoad() LoadMap {
599607
this.throttleMutex.Lock()
600608
defer this.throttleMutex.Unlock()

go/cmd/gh-ost/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func main() {
106106
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")
107107
throttleQuery := flag.String("throttle-query", "", "when given, issued (every second) to check if operation should throttle. Expecting to return zero for no-throttle, >0 for throttle. Query is issued on the migrated server. Make sure this query is lightweight")
108108
throttleHTTP := flag.String("throttle-http", "", "when given, gh-ost checks given URL via HEAD request; any response code other than 200 (OK) causes throttling; make sure it has low latency response")
109+
ignoreHTTPErrors := flag.Bool("ignore-http-errors", false, "ignore HTTP connection errors during throttle check")
109110
heartbeatIntervalMillis := flag.Int64("heartbeat-interval-millis", 100, "how frequently would gh-ost inject a heartbeat value")
110111
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")
111112
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")
@@ -259,6 +260,7 @@ func main() {
259260
migrationContext.SetMaxLagMillisecondsThrottleThreshold(*maxLagMillis)
260261
migrationContext.SetThrottleQuery(*throttleQuery)
261262
migrationContext.SetThrottleHTTP(*throttleHTTP)
263+
migrationContext.SetIgnoreHTTPErrors(*ignoreHTTPErrors)
262264
migrationContext.SetDefaultNumRetries(*defaultRetries)
263265
migrationContext.ApplyCredentials()
264266
if err := migrationContext.SetupTLS(); err != nil {

go/logic/throttler.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ import (
1818
)
1919

2020
var (
21-
httpStatusMessages map[int]string = map[int]string{
21+
httpStatusMessages = map[int]string{
2222
200: "OK",
2323
404: "Not found",
2424
417: "Expectation failed",
2525
429: "Too many requests",
2626
500: "Internal server error",
27+
-1: "Connection error",
2728
}
2829
// See https://github.com/github/freno/blob/master/doc/http.md
29-
httpStatusFrenoMessages map[int]string = map[int]string{
30+
httpStatusFrenoMessages = map[int]string{
3031
200: "OK",
3132
404: "freno: unknown metric",
3233
417: "freno: access forbidden",
3334
429: "freno: threshold exceeded",
3435
500: "freno: internal error",
36+
-1: "freno: connection error",
3537
}
3638
)
3739

@@ -83,6 +85,7 @@ func (this *Throttler) shouldThrottle() (result bool, reason string, reasonHint
8385
if statusCode != 0 && statusCode != http.StatusOK {
8486
return true, this.throttleHttpMessage(int(statusCode)), base.NoThrottleReasonHint
8587
}
88+
8689
// Replication lag throttle
8790
maxLagMillisecondsThrottleThreshold := atomic.LoadInt64(&this.migrationContext.MaxLagMillisecondsThrottleThreshold)
8891
lag := atomic.LoadInt64(&this.migrationContext.CurrentLag)
@@ -287,7 +290,14 @@ func (this *Throttler) collectThrottleHTTPStatus(firstThrottlingCollected chan<-
287290
return false, nil
288291
}
289292

290-
collectFunc()
293+
_, err := collectFunc()
294+
if err != nil {
295+
// If not told to ignore errors, we'll throttle on HTTP connection issues
296+
if !this.migrationContext.IgnoreHTTPErrors {
297+
atomic.StoreInt64(&this.migrationContext.ThrottleHTTPStatusCode, int64(-1))
298+
}
299+
}
300+
291301
firstThrottlingCollected <- true
292302

293303
ticker := time.Tick(100 * time.Millisecond)
@@ -296,7 +306,15 @@ func (this *Throttler) collectThrottleHTTPStatus(firstThrottlingCollected chan<-
296306
return
297307
}
298308

299-
if sleep, _ := collectFunc(); sleep {
309+
sleep, err := collectFunc()
310+
if err != nil {
311+
// If not told to ignore errors, we'll throttle on HTTP connection issues
312+
if !this.migrationContext.IgnoreHTTPErrors {
313+
atomic.StoreInt64(&this.migrationContext.ThrottleHTTPStatusCode, int64(-1))
314+
}
315+
}
316+
317+
if sleep {
300318
time.Sleep(1 * time.Second)
301319
}
302320
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
id bigint auto_increment,
4+
val bigint not null,
5+
primary key(id)
6+
) auto_increment=1;
7+
8+
drop event if exists gh_ost_test;
9+
delimiter ;;
10+
create event gh_ost_test
11+
on schedule every 1 second
12+
starts current_timestamp
13+
ends current_timestamp + interval 60 second
14+
on completion not preserve
15+
enable
16+
do
17+
begin
18+
insert into gh_ost_test values (null, 18446744073709551615);
19+
insert into gh_ost_test values (null, 18446744073709551614);
20+
insert into gh_ost_test values (null, 18446744073709551613);
21+
end ;;

0 commit comments

Comments
 (0)