Skip to content

Commit bf160d5

Browse files
committed
Merge branch 'master' into meiji163/bit-key-bug
2 parents 72a7b6e + 1557a95 commit bf160d5

File tree

1,111 files changed

+215784
-13383
lines changed

Some content is hidden

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

1,111 files changed

+215784
-13383
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212

1313
- name: Set up Go
14-
uses: actions/setup-go@v5
14+
uses: actions/setup-go@v6
1515
with:
1616
go-version-file: go.mod
1717

.github/workflows/codeql.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717

1818
strategy:
1919
fail-fast: false
20+
matrix:
21+
language: [ 'actions', 'go' ]
2022

2123
runs-on: ubuntu-latest # windows-latest and ubuntu-latest are supported. macos-latest is not supported at this time.
2224

@@ -26,6 +28,8 @@ jobs:
2628

2729
- name: Initialize CodeQL
2830
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
2933

3034
- name: Perform CodeQL Analysis
3135
uses: github/codeql-action/analyze@v3

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- uses: actions/setup-go@v5
17+
- uses: actions/setup-go@v6
1818
with:
1919
go-version-file: go.mod
2020
- name: golangci-lint
2121
uses: golangci/golangci-lint-action@v6
2222
with:
23-
version: v1.54.2
23+
version: v1.61.0

.github/workflows/replica-tests.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,29 @@ name: migration tests
33
on: [pull_request]
44

55
jobs:
6-
build:
7-
8-
runs-on: ubuntu-20.04
6+
docker-tests:
7+
runs-on: ubuntu-22.04
98
strategy:
9+
fail-fast: false
1010
matrix:
11-
version: [mysql-5.7.25,mysql-8.0.16,PerconaServer-8.0.21]
11+
image: ['mysql/mysql-server:5.7.41','mysql:8.0.41','mysql:8.4.3','percona/percona-server:8.0.41-32']
12+
env:
13+
TEST_MYSQL_IMAGE: ${{ matrix.image }}
1214

1315
steps:
14-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v4
17+
18+
- name: Install sysbench
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y sysbench
22+
23+
- name: Setup environment
24+
run: script/docker-gh-ost-replica-tests up
1525

16-
- name: Set up Go
17-
uses: actions/setup-go@v5
18-
with:
19-
go-version-file: go.mod
26+
- name: Run tests
27+
run: script/docker-gh-ost-replica-tests run
2028

21-
- name: migration tests
22-
env:
23-
TEST_MYSQL_VERSION: ${{ matrix.version }}
24-
run: script/cibuild-gh-ost-replica-tests
29+
- name: Teardown environment
30+
if: always()
31+
run: script/docker-gh-ost-replica-tests down

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ linters:
1111
- durationcheck
1212
- errname
1313
- errorlint
14-
- execinquery
1514
- gofmt
16-
- ifshort
1715
- misspell
1816
- nilerr
1917
- nilnil

Dockerfile.packaging

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye
1+
FROM golang:1.23-bullseye
22

33
RUN apt-get update
44
RUN apt-get install -y ruby ruby-dev rubygems build-essential

Dockerfile.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye
1+
FROM golang:1.23-bullseye
22
LABEL maintainer="[email protected]"
33

44
RUN apt-get update

doc/command-line-flags.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ It is not reliable to parse the `ALTER` statement to determine if it is instant
6464
### binlogsyncer-max-reconnect-attempts
6565
`--binlogsyncer-max-reconnect-attempts=0`, the maximum number of attempts to re-establish a broken inspector connection for sync binlog. `0` or `negative number` means infinite retry, default `0`
6666

67+
### checkpoint
68+
69+
`--checkpoint` enables periodic checkpoints of the gh-ost's state so that gh-ost can resume a migration from the checkpoint with `--resume`. Checkpoints are written to a separate table named `_${original_table_name}_ghk`. It is recommended to use with `--gtid` for checkpoints.
70+
See also: [`resuming-migrations`](resume.md)
71+
72+
### checkpoint-seconds
73+
74+
`--checkpoint-seconds` specifies the seconds between checkpoints. Default is 300.
75+
6776
### conf
6877

6978
`--conf=/path/to/my.cnf`: file where credentials are specified. Should be in (or contain) the following format:
@@ -119,7 +128,7 @@ See also: [`skip-foreign-key-checks`](#skip-foreign-key-checks)
119128

120129
`gh-ost` reads event from the binary log and applies them onto the _ghost_ table. It does so in batched writes: grouping multiple events to apply in a single transaction. This gives better write throughput as we don't need to sync the transaction log to disk for each event.
121130

122-
The `--dml-batch-size` flag controls the size of the batched write. Allowed values are `1 - 100`, where `1` means no batching (every event from the binary log is applied onto the _ghost_ table on its own transaction). Default value is `10`.
131+
The `--dml-batch-size` flag controls the size of the batched write. Allowed values are `1 - 1000`, where `1` means no batching (every event from the binary log is applied onto the _ghost_ table on its own transaction). Default value is `10`.
123132

124133
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.
125134

@@ -160,6 +169,10 @@ Table name prefix to be used on the temporary tables.
160169

161170
Add this flag when executing on a 1st generation Google Cloud Platform (GCP).
162171

172+
### gtid
173+
174+
Add this flag to enable support for [MySQL replication GTIDs](https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-concepts.html) for replication positioning. This requires `gtid_mode` and `enforce_gtid_consistency` to be set to `ON`.
175+
163176
### heartbeat-interval-millis
164177

165178
Default 100. See [`subsecond-lag`](subsecond-lag.md) for details.
@@ -202,6 +215,12 @@ List of metrics and threshold values; topping the threshold of any will cause th
202215

203216
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.
204217

218+
### panic-on-warnings
219+
220+
When this flag is set, `gh-ost` will panic when SQL warnings indicating data loss are encountered when copying data. This flag helps prevent data loss scenarios with migrations touching unique keys, column collation and types, as well as `NOT NULL` constraints, where `MySQL` will silently drop inserted rows that no longer satisfy the updated constraint (also dependent on the configured `sql_mode`).
221+
222+
While `panic-on-warnings` is currently disabled by defaults, it will default to `true` in a future version of `gh-ost`.
223+
205224
### postpone-cut-over-flag-file
206225

207226
Indicate a file name, such that the final [cut-over](cut-over.md) step does not take place as long as the file exists.
@@ -216,6 +235,11 @@ Optionally involve the process ID, for example: `--replica-server-id=$((10000000
216235
It's on you to choose a number that does not collide with another `gh-ost` or another running replica.
217236
See also: [`concurrent-migrations`](cheatsheet.md#concurrent-migrations) on the cheatsheet.
218237

238+
### resume
239+
240+
`--resume` attempts to resume a migration that was previously interrupted from the last checkpoint. The first `gh-ost` invocation must run with `--checkpoint` and have successfully written a checkpoint in order for `--resume` to work.
241+
See also: [`resuming-migrations`](resume.md)
242+
219243
### serve-socket-file
220244

221245
Defaults to an auto-determined and advertised upon startup file. Defines Unix socket file to serve on.

doc/interactive-commands.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Both interfaces may serve at the same time. Both respond to simple text command,
4141
- `throttle-control-replicas='replica1,replica2'`: change list of throttle-control replicas, these are replicas `gh-ost` will check. This takes a comma separated list of replica's to check and replaces the previous list.
4242
- `throttle`: force migration suspend
4343
- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply)
44+
- `postpone-cut-over-flag-file=<path>`: Postpone the [cut-over](cut-over.md) phase, writing a cut over flag file to the given path
4445
- `unpostpone`: at a time where `gh-ost` is postponing the [cut-over](cut-over.md) phase, instruct `gh-ost` to stop postponing and proceed immediately to cut-over.
4546
- `panic`: immediately panic and abort operation
4647

@@ -60,7 +61,7 @@ $ echo status | nc -U /tmp/gh-ost.test.sample_data_0.sock
6061
# Throttle additional flag file: /tmp/gh-ost.throttle
6162
# Serving on unix socket: /tmp/gh-ost.test.sample_data_0.sock
6263
# Serving on TCP port: 10001
63-
Copy: 0/2915 0.0%; Applied: 0; Backlog: 0/100; Elapsed: 40s(copy), 41s(total); streamer: mysql-bin.000550:49942; ETA: throttled, flag-file
64+
Copy: 0/2915 0.0%; Applied: 0; Backlog: 0/100; Time: 41s(total), 40s(copy); streamer: mysql-bin.000550:49942; Lag: 0.01s, HeartbeatLag: 0.01s, State: throttled, flag-file; ETA: N/A
6465
```
6566

6667
```shell
@@ -88,5 +89,5 @@ $ echo status | nc -U /tmp/gh-ost.test.sample_data_0.sock
8889
# Throttle additional flag file: /tmp/gh-ost.throttle
8990
# Serving on unix socket: /tmp/gh-ost.test.sample_data_0.sock
9091
# Serving on TCP port: 10001
91-
Copy: 0/2915 0.0%; Applied: 0; Backlog: 0/100; Elapsed: 59s(copy), 59s(total); streamer: mysql-bin.000551:68067; ETA: throttled, commanded by user
92+
Copy: 0/2915 0.0%; Applied: 0; Backlog: 0/100; Time: 59s(total), 59s(copy); streamer: mysql-bin.000551:68067; Lag: 0.01s, HeartbeatLag: 0.01s, State: throttled, commanded by user; ETA: N/A
9293
```

doc/local-tests.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`gh-ost` is continuously tested in production via `--test-on-replica alter='engine=innodb'`. These tests check the GitHub workload and usage, but not necessarily the general case.
44

5-
Local tests are an additional layer of tests. They will eventually be part of continuous integration tests.
5+
Local tests are an additional layer of tests used for continuous integration tests and local development.
66

77
Local tests test explicit use cases, such as column renames, mix of time zones, special types and alters. Traits of a single test:
88

@@ -19,4 +19,26 @@ Tests are found under [localtests](https://github.com/github/gh-ost/tree/master/
1919

2020
New data-integrity, synchronization issues or otherwise concerns are expected to be tested by new test cases.
2121

22-
While this is merged work is still ongoing.
22+
## Run with docker compose
23+
24+
Local tests can be run locally with docker compose using the helper script [script/docker-gh-ost-replica-tests](https://github.com/github/gh-ost/tree/master/script/docker-gh-ost-replica-tests).
25+
26+
Example usage:
27+
```shell
28+
# create primary-replica containers with specified mysql image
29+
TEST_MYSQL_IMAGE="mysql-server:8.0.16" ./script/docker-gh-ost-replica-tests up
30+
31+
# run all tests
32+
./script/docker-gh-ost-replica-tests run
33+
34+
# cleanup containers
35+
./script/docker-gh-ost-replica-tests down
36+
```
37+
38+
Pass the `-t` flag to run the tests with a toxiproxy between gh-ost and the MySQL replica. This simulates network conditions where MySQL connections are closed unexpectedly.
39+
40+
```shell
41+
# run tests with toxiproxy
42+
./script/docker-gh-ost-replica-tests up -t
43+
./script/docker-gh-ost-replica-tests run -t
44+
```

0 commit comments

Comments
 (0)