Skip to content

Commit c9d02b9

Browse files
author
Shlomi Noach
authored
Merge pull request #52 from github/more-documentation
more documentation updates
2 parents 57347ec + 6338a38 commit c9d02b9

File tree

6 files changed

+56
-19
lines changed

6 files changed

+56
-19
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,22 @@
1212

1313
WORK IN PROGRESS
1414

15-
Please meanwhile refer to the [docs](doc) for more information.
15+
Please meanwhile refer to the [docs](doc) for more information. No, really, go to the [docs](doc).
16+
17+
## Usage
18+
19+
#### Testing on replica
20+
21+
```
22+
gh-ost --conf=.my.cnf --database=mydb --table=mytable --verbose --alter="engine=innodb" --execute --initially-drop-ghost-table --initially-drop-old-table -max-load=Threads_connected=30 --switch-to-rbr --chunk-size=2500 --cut-over=two-step --exact-rowcount --test-on-replica --verbose
23+
```
24+
Please read more on [testing on replica](testing-on-replica.md)
25+
26+
#### Executing on master
27+
28+
```
29+
gh-ost --conf=.my.cnf --database=mydb --table=mytable --verbose --alter="engine=innodb" --execute --initially-drop-ghost-table --initially-drop-old-table -max-load=Threads_connected=30 --switch-to-rbr --chunk-size=2500 --cut-over=two-step --exact-rowcount --verbose
30+
```
1631

1732
## What's in a name?
1833

doc/command-line-flags.md

Lines changed: 12 additions & 0 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+
##### cut-over
6+
7+
Required. You are asked to explicitly state which cut-over algorithm you wish to use. Please see more discussion on [cut-over](cut-over.md)
8+
59
##### exact-rowcount
610

711
A `gh-ost` execution need to copy whatever rows you have in your existing table onto the ghost table. This can, and often be, a large number. Exactly what that number is?
@@ -14,3 +18,11 @@ A `gh-ost` execution need to copy whatever rows you have in your existing table
1418
We heuristically update the number of rows based on the queries we process from the binlogs.
1519

1620
While the ongoing estimated number of rows is still heuristic, it's almost exact, such that the reported [ETA](understanding-output.md) or percentage progress is typically accurate to the second throughout a multiple-hour operation.
21+
22+
##### noop
23+
24+
Do cheks; create ghost table and verify migration would be valid, but do not actually migrate and do not touch data.
25+
26+
##### test-on-replica
27+
28+
Issue the migration on a replica; do not modify data on master. Useful for validating, testing and benchmarking. See [test-on-replica](test-on-replica.md)

doc/cut-over.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Cut-over step
2+
3+
The cut-over is the final major step of the migration: it's the moment where your original table is pushed aside, and the ghost table (the one we secretly altered and operated on throughout the process) takes its place.
4+
5+
MySQL poses some limitations on how the table swap can take place. While it supports an atomic swap, it does not allow for a swap under controlled lock.
6+
7+
The [facebook OSC](https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932/) tool documents this nicely. Look for **"Cut-over phase"**.
8+
9+
`gh-ost` supports various types of cut-over options:
10+
11+
- `--cut-over=two-step` - this method is similar to the one taken by the facebook OSC. It's non-blocking but also non-atomic. The original table is first renames and pushed aside, then the ghost table is renamed to take its place. In between the two renames there's a brief period of time where your table just does not exist, and queries will fail.
12+
- `--cut-over=voluntary-lock` - as depicted in [Solving the Facebook-OSC non-atomic table swap problem](http://code.openark.org/blog/mysql/solving-the-facebook-osc-non-atomic-table-swap-problem), this solution uses voluntary MySQL locks, and makes for a blocking swap, where your queries do not fail, but block until operation is complete. This effect is desired. There is danger in this solution, since connection failure of the two sessions involved in creating the lock, would result in a premature swap of the tables, hence with potentially corrupted data.
13+
- We are working at this time on a blocking, safe, atomic solution, using wait conditions and via User Defined Functions which will need to be dynamically loaded onto your MySQL server. See [udf-ghost-wait-condition](https://github.com/openark/udf-ghost-wait-condition)
14+
- With [`--test-on-replica`](testing-on-replica.md) there is no table swap (**NOTE**: this is going to change. We will do cut-over on replica in exact same way as on master so as to invoke exact flow)

doc/swapping-tables.md

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

doc/testing-on-replica.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ It's your job to:
4747

4848
Simple:
4949
```shell
50-
$ gh-osc --host=myhost.com --conf=/etc/gh-ost.cnf --database=test --table=sample_table --alter="engine=innodb" --chunk-size=2000 --max-load=Threads_connected=20 --initially-drop-ghost-table --initially-drop-old-table --test-on-replica --verbose --execute
50+
$ gh-osc --host=myhost.com --conf=/etc/gh-ost.cnf --database=test --table=sample_table --alter="engine=innodb" --chunk-size=2000 --max-load=Threads_connected=20 --initially-drop-ghost-table --initially-drop-old-table --cut-over=voluntary-lock --test-on-replica --verbose --execute
5151
```
5252

5353
Elaborate:
5454
```shell
55-
$ gh-osc --host=myhost.com --conf=/etc/gh-ost.cnf --database=test --table=sample_table --alter="engine=innodb" --chunk-size=2000 --max-load=Threads_connected=20 --switch-to-rbr --initially-drop-ghost-table --initially-drop-old-table --test-on-replica --postpone-swap-tables-flag-file=/tmp/ghost-postpone.flag --exact-rowcount --allow-nullable-unique-key --verbose --execute
55+
$ gh-osc --host=myhost.com --conf=/etc/gh-ost.cnf --database=test --table=sample_table --alter="engine=innodb" --chunk-size=2000 --max-load=Threads_connected=20 --switch-to-rbr --initially-drop-ghost-table --initially-drop-old-table --cut-over=voluntary-lock --test-on-replica --postpone-swap-tables-flag-file=/tmp/ghost-postpone.flag --exact-rowcount --allow-nullable-unique-key --verbose --execute
5656
```
5757
- Count exact number of rows (makes ETA estimation very good). This goes at the expense of paying the time for issuing a `SELECT COUNT(*)` on your table. We use this lovingly.
5858
- Automatically switch to `RBR` if replica is configured as `SBR`. See also: [migrating with SBR](migrating-with-sbr.md)

doc/understanding-output.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,15 @@ Copy: 4466492/4467235 100.0%; Applied: 23309; Backlog: 1/100; Elapsed: 7m18s(cop
134134
2016-05-19 18:04:30 INFO Done waiting for events up to lock
135135
Copy: 4466492/4467235 100.0%; Applied: 23309; Backlog: 0/100; Elapsed: 7m18s(copy), 7m25s(total); streamer: mysql-bin.002589:17703056; ETA: 0s
136136
```
137-
This migration took, till this point, `7m25s`, had applied `23309` events from the binary log and has copied `4466492` rows onto the ghost table.
138-
137+
This migration - insofar - took `7m25s`, has applied `23309` events from the binary log and has copied `4466492` rows onto the ghost table.
138+
139+
## Status hint
140+
141+
In addition, once every `10` minutes, a friendly reminder is printed, in the following form:
142+
143+
```
144+
# Migrating `mydb`.`mytable`; Ghost table is `mydb`.`_mytable_gst`
145+
# Migration started at Mon Jun 06 03:45:08 -0700 2016
146+
# chunk-size: 2500; max lag: 1500ms; max-load: map[Threads_connected:30]
147+
# Throttle additional flag file: /tmp/gh-ost.throttle
148+
```

0 commit comments

Comments
 (0)