Skip to content

Commit

Permalink
Merge branch 'main' into jayj/old-table-timestamped
Browse files Browse the repository at this point in the history
  • Loading branch information
jayjanssen authored Jun 27, 2024
2 parents 2ffc07f + 8c08e63 commit a7bf8ec
Show file tree
Hide file tree
Showing 53 changed files with 806 additions and 97 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/buildandrun-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: MySQL 8.0 Build and Run /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build and Run Spirit
run: docker compose up mysql buildandrun --abort-on-container-exit
working-directory: compose
2 changes: 1 addition & 1 deletion .github/workflows/buildandrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54.2
version: v1.59.1
args: --timeout=2m
16 changes: 16 additions & 0 deletions .github/workflows/mysql8-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: MySQL 8.0.33 (with replicas) /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml up mysql mysql_replica test --abort-on-container-exit
working-directory: compose/replication
16 changes: 16 additions & 0 deletions .github/workflows/mysql8.0.28-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: MySQL 8.0.28 (Aurora version) /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml -f 8.0.28.yml up mysql test --abort-on-container-exit
working-directory: compose
2 changes: 1 addition & 1 deletion .github/workflows/mysql8.0.28.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mysql8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4

Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/mysql84-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: MySQL 8.4 GA /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml -f 8.4.yml up mysql mysql_replica test --abort-on-container-exit
working-directory: compose/replication
2 changes: 1 addition & 1 deletion .github/workflows/mysql84.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4

Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/mysql8_rbr_minimal-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: MySQL 8.0.33 (RBR minimal) /w docker-compose
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: docker compose -f compose.yml -f 8.0.33-rbr-minimal.yml up mysql test --abort-on-container-exit
working-directory: compose
2 changes: 1 addition & 1 deletion .github/workflows/mysql8_rbr_minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout code
uses: actions/checkout@v4

Expand Down
16 changes: 8 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ linters:
disable:
- tagalign
- depguard
- mnd
- musttag
- nonamedreturns
- exhaustruct
Expand All @@ -26,7 +27,6 @@ linters:
- ireturn
- maintidx
- nilnil
- maligned
- lll
- gochecknoglobals
- wsl
Expand All @@ -36,21 +36,16 @@ linters:
- goprintffuncname
- paralleltest
- nlreturn
- goerr113
- ifshort
- err113
- testpackage
- wrapcheck
- exhaustivestruct
- forbidigo
- gci
- godot
- gofumpt
- cyclop
- errorlint
- nestif
- golint
- scopelint
- interfacer
- tagliatelle
- thelper
- godox
Expand All @@ -65,6 +60,12 @@ linters-settings:
min-complexity: 20
exhaustive:
default-signifies-exhaustive: true
testifylint:
enable-all: true
disable:
- suite-thelper # this is disabled by default
- float-compare
- require-error

issues:
max-per-linter: 0
Expand All @@ -79,4 +80,3 @@ issues:
- 'bad syntax for struct tag key'
- 'bad syntax for struct tag pair'
- 'result .* \(error\) is always nil'

2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Minimum Requirements

Spirit requires go 1.21 or higher. MySQL version 8.0 and higher is required for performing schema changes.
Spirit requires go 1.22 or higher. MySQL version 8.0 and higher is required for performing schema changes.

## Running tests

Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM golang:1.22

WORKDIR /app
COPY ../go.mod go.sum ./
RUN go mod download
COPY .. .
11 changes: 11 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,14 @@ You can resume a migration from checkpoint and Spirit will start waiting again f
If you start a migration and realize that you forgot to set defer-cutover, worry not! You can manually create a sentinel table using the pattern `_<table>_sentinel`, and Spirit will detect the table before the cutover is completed and block as though defer-cutover had been enabled from the beginning.

Note that the checksum, if enabled, will be computed after the sentinel table is dropped. Because the checksum step takes an estimated 10-20% of the migration, the cutover will not occur immediately after the sentinel table is dropped.

### strict

- Type: Boolean
- Default value: FALSE

By default, Spirit will automatically clean up these old checkpoints before starting the schema change. This allows schema changes to always be possible to proceed forward, at the risk of lost progress.

When set to `TRUE`, if Spirit encounters a checkpoint belonging to a previous migration, it will validate that the alter statement matches the `--alter` parameter. If the validation fails, spirit will exit and prevent the schema change process from proceeding.


5 changes: 5 additions & 0 deletions compose/8.0.28.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
mysql:
image: mysql:8.0.28
platform: linux/amd64
ports: [ '8028:3306' ]
5 changes: 5 additions & 0 deletions compose/8.0.33-rbr-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
mysql:
image: mysql:8.0.33
ports: [ '8033:3306' ]
command: --binlog-row-image=MINIMAL
37 changes: 37 additions & 0 deletions compose/bootstrap.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use mysql;

create role if not exists R_MIGRATOR;
grant alter, create, delete, drop, index, insert, lock tables, select, trigger, update on *.* to R_MIGRATOR;
create role if not exists R_REPLICATION;
grant replication slave, replication client on *.* to R_REPLICATION;
create role if not exists R_THROTTLER;
grant select on performance_schema.replication_applier_status_by_worker to R_THROTTLER;
grant select on performance_schema.replication_connection_status to R_THROTTLER;

create user if not exists msandbox@'%' identified with caching_sha2_password by 'msandbox';
grant R_MIGRATOR, R_REPLICATION to msandbox@'%';
set default role R_MIGRATOR, R_REPLICATION to msandbox@'%';

create user if not exists rsandbox@'%' identified with caching_sha2_password by 'rsandbox';
grant R_REPLICATION, R_THROTTLER to rsandbox@'%';
set default role R_REPLICATION, R_THROTTLER to rsandbox@'%';

-- unfortunately the password for tsandbox must be the same as the password for root because in tests we switch to root
-- using the same password.
create user if not exists tsandbox@'%' identified with caching_sha2_password by 'msandbox';
grant R_MIGRATOR, R_REPLICATION to tsandbox@'%';
grant references, super, process on *.* to tsandbox@'%'; -- used in tests
set default role R_MIGRATOR, R_REPLICATION to tsandbox@'%';

flush privileges;

create database if not exists test;

use test;

create table t1
(
id int not null primary key auto_increment,
b int not null,
c int not null
);
46 changes: 46 additions & 0 deletions compose/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
mysql:
image: mysql:8.0.33
ports: [ '8033:3306' ]
# to supress mbind: Operation not permitted in CI
# https://stackoverflow.com/a/55706057
cap_add:
- SYS_NICE
environment:
MYSQL_ROOT_PASSWORD: msandbox
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
start_period: 1s
interval: 1s
timeout: 2s
retries: 60
volumes:
- mysql-standalone-data-dir:/var/lib/mysql
- ./bootstrap.sql:/docker-entrypoint-initdb.d/bootstrap.sql

test:
build:
context: ../
command: go test -race -v ./...
depends_on:
mysql:
condition: service_healthy
environment:
MYSQL_DSN: tsandbox:msandbox@tcp(mysql)/test

buildandrun:
build:
context: ../
command: scripts/buildandrun.sh
depends_on:
mysql:
condition: service_healthy
environment:
HOST: mysql:3306
USERNAME: msandbox
PASSWORD: msandbox
DATABASE: test
TABLE: t1

volumes:
mysql-standalone-data-dir:
9 changes: 9 additions & 0 deletions compose/replication/8.0.28.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
mysql:
image: mysql:8.0.28
platform: linux/amd64
ports: [ '8028:3306' ]
mysql_replica:
image: mysql:8.0.28
platform: linux/amd64
ports: [ '8128:3306' ]
8 changes: 8 additions & 0 deletions compose/replication/8.0.33-rbr-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
mysql:
image: mysql:8.0.33
ports: [ '8033:3306' ]
command: --binlog-row-image=MINIMAL --server-id=1 --log-bin=mysql-bin --gtid-mode=on --enforce-gtid-consistency=on
mysql_replica:
image: mysql:8.0.33
ports: [ '8133:3306' ]
7 changes: 7 additions & 0 deletions compose/replication/8.4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
mysql:
image: mysql:8.4
ports: [ '8040:3306' ]
mysql_replica:
image: mysql:8.4
ports: [ '8141:3306' ]
1 change: 1 addition & 0 deletions compose/replication/bootstrap_replica.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
change replication source to source_host='mysql',source_user='rsandbox',source_password='rsandbox',source_auto_position=1,get_source_public_key=1;
Loading

0 comments on commit a7bf8ec

Please sign in to comment.