Skip to content

Commit 02f75b7

Browse files
author
Gonlo2
authored
Merge branch 'master' into add-galera-support
2 parents 434ace4 + ea339b6 commit 02f75b7

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

doc/command-line-flags.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If, for some reason, you do not wish `gh-ost` to connect to a replica, you may c
1818

1919
### approve-renamed-columns
2020

21-
When your migration issues a column rename (`change column old_name new_name ...`) `gh-ost` analyzes the statement to try an associate the old column name with new column name. Otherwise the new structure may also look like some column was dropped and another was added.
21+
When your migration issues a column rename (`change column old_name new_name ...`) `gh-ost` analyzes the statement to try and associate the old column name with new column name. Otherwise the new structure may also look like some column was dropped and another was added.
2222

2323
`gh-ost` will print out what it thinks the _rename_ implied, but will not issue the migration unless you provide with `--approve-renamed-columns`.
2424

@@ -161,7 +161,7 @@ List of metrics and threshold values; topping the threshold of any will cause th
161161

162162
### migrate-on-replica
163163

164-
Typically `gh-ost` is used to migrate tables on a master. If you wish to only perform the migration in full on a replica, connect `gh-ost` to said replica and pass `--migrate-on-replica`. `gh-ost` will briefly connect to the master but other issue no changes on the master. Migration will be fully executed on the replica, while making sure to maintain a small replication lag.
164+
Typically `gh-ost` is used to migrate tables on a master. If you wish to only perform the migration in full on a replica, connect `gh-ost` to said replica and pass `--migrate-on-replica`. `gh-ost` will briefly connect to the master but otherwise will make no changes on the master. Migration will be fully executed on the replica, while making sure to maintain a small replication lag.
165165

166166
### postpone-cut-over-flag-file
167167

doc/hooks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The following variables are available on all hooks:
6565
- `GH_OST_ELAPSED_COPY_SECONDS` - row-copy time (excluding startup, row-count and postpone time)
6666
- `GH_OST_ESTIMATED_ROWS` - estimated total rows in table
6767
- `GH_OST_COPIED_ROWS` - number of rows copied by `gh-ost`
68+
- `GH_OST_INSPECTED_LAG` - lag in seconds (floating point) of inspected server
69+
- `GH_OST_PROGRESS` - progress pct ([0..100], floating point) of migration
6870
- `GH_OST_MIGRATED_HOST`
6971
- `GH_OST_INSPECTED_HOST`
7072
- `GH_OST_EXECUTING_HOST`

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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package base
77

88
import (
99
"fmt"
10+
"math"
1011
"os"
1112
"regexp"
1213
"strings"
@@ -176,6 +177,7 @@ type MigrationContext struct {
176177
pointOfInterestTime time.Time
177178
pointOfInterestTimeMutex *sync.Mutex
178179
CurrentLag int64
180+
currentProgress uint64
179181
ThrottleHTTPStatusCode int64
180182
controlReplicasLagResult mysql.ReplicationLagResult
181183
TotalRowsCopied int64
@@ -433,6 +435,20 @@ func (this *MigrationContext) MarkRowCopyEndTime() {
433435
this.RowCopyEndTime = time.Now()
434436
}
435437

438+
func (this *MigrationContext) GetCurrentLagDuration() time.Duration {
439+
return time.Duration(atomic.LoadInt64(&this.CurrentLag))
440+
}
441+
442+
func (this *MigrationContext) GetProgressPct() float64 {
443+
return math.Float64frombits(atomic.LoadUint64(&this.currentProgress))
444+
}
445+
446+
func (this *MigrationContext) SetProgressPct(progressPct float64) {
447+
atomic.StoreUint64(&this.currentProgress, math.Float64bits(progressPct))
448+
}
449+
450+
// math.Float64bits([f=0..100])
451+
436452
// GetTotalRowsCopied returns the accurate number of rows being copied (affected)
437453
// This is not exactly the same as the rows being iterated via chunks, but potentially close enough
438454
func (this *MigrationContext) GetTotalRowsCopied() int64 {

go/logic/hooks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func (this *HooksExecutor) applyEnvironmentVariables(extraVariables ...string) [
6363
env = append(env, fmt.Sprintf("GH_OST_MIGRATED_HOST=%s", this.migrationContext.GetApplierHostname()))
6464
env = append(env, fmt.Sprintf("GH_OST_INSPECTED_HOST=%s", this.migrationContext.GetInspectorHostname()))
6565
env = append(env, fmt.Sprintf("GH_OST_EXECUTING_HOST=%s", this.migrationContext.Hostname))
66+
env = append(env, fmt.Sprintf("GH_OST_INSPECTED_LAG=%f", this.migrationContext.GetCurrentLagDuration().Seconds()))
67+
env = append(env, fmt.Sprintf("GH_OST_PROGRESS=%f", this.migrationContext.GetProgressPct()))
6668
env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT=%s", this.migrationContext.HooksHintMessage))
6769
env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT_OWNER=%s", this.migrationContext.HooksHintOwner))
6870
env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT_TOKEN=%s", this.migrationContext.HooksHintToken))

go/logic/migrator.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,8 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
10891089
} else {
10901090
progressPct = 100.0 * float64(totalRowsCopied) / float64(rowsEstimate)
10911091
}
1092+
// we take the opportunity to update migration context with progressPct
1093+
this.migrationContext.SetProgressPct(progressPct)
10921094
// Before status, let's see if we should print a nice reminder for what exactly we're doing here.
10931095
shouldPrintMigrationStatusHint := (elapsedSeconds%600 == 0)
10941096
if rule == ForcePrintStatusAndHintRule {
@@ -1105,7 +1107,7 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
11051107
eta := "N/A"
11061108
if progressPct >= 100.0 {
11071109
eta = "due"
1108-
} else if progressPct >= 1.0 {
1110+
} else if progressPct >= 0.1 {
11091111
elapsedRowCopySeconds := this.migrationContext.ElapsedRowCopyTime().Seconds()
11101112
totalExpectedSeconds := elapsedRowCopySeconds * float64(rowsEstimate) / float64(totalRowsCopied)
11111113
etaSeconds = totalExpectedSeconds - elapsedRowCopySeconds
@@ -1152,12 +1154,13 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
11521154

11531155
currentBinlogCoordinates := *this.eventsStreamer.GetCurrentBinlogCoordinates()
11541156

1155-
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; State: %s; ETA: %s",
1157+
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; Lag: %.2fs, State: %s; ETA: %s",
11561158
totalRowsCopied, rowsEstimate, progressPct,
11571159
atomic.LoadInt64(&this.migrationContext.TotalDMLEventsApplied),
11581160
len(this.applyEventsQueue), cap(this.applyEventsQueue),
11591161
base.PrettifyDurationOutput(elapsedTime), base.PrettifyDurationOutput(this.migrationContext.ElapsedRowCopyTime()),
11601162
currentBinlogCoordinates,
1163+
this.migrationContext.GetCurrentLagDuration().Seconds(),
11611164
state,
11621165
eta,
11631166
)

0 commit comments

Comments
 (0)