Skip to content

Commit c844981

Browse files
authored
Merge branch 'master' into 1386-instant-lock-timeout
2 parents d5f9aff + 4b0ac90 commit c844981

File tree

139 files changed

+3043
-1619
lines changed

Some content is hidden

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

139 files changed

+3043
-1619
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/libexec/
44
/.vendor/
55
.idea/
6+
*.tmp

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ require (
1111
github.com/stretchr/testify v1.9.0
1212
github.com/testcontainers/testcontainers-go v0.34.0
1313
golang.org/x/net v0.24.0
14-
golang.org/x/sync v0.8.0
15-
golang.org/x/term v0.19.0
16-
golang.org/x/text v0.14.0
14+
golang.org/x/sync v0.10.0
15+
golang.org/x/term v0.27.0
16+
golang.org/x/text v0.21.0
1717
)
1818

1919
require (
@@ -66,7 +66,7 @@ require (
6666
go.opentelemetry.io/otel/metric v1.24.0 // indirect
6767
go.opentelemetry.io/otel/trace v1.24.0 // indirect
6868
go.uber.org/atomic v1.7.0 // indirect
69-
golang.org/x/crypto v0.22.0 // indirect
70-
golang.org/x/sys v0.21.0 // indirect
69+
golang.org/x/crypto v0.31.0 // indirect
70+
golang.org/x/sys v0.28.0 // indirect
7171
gopkg.in/yaml.v3 v3.0.1 // indirect
7272
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
183183
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
184184
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
185185
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
186-
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
187-
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
186+
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
187+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
188188
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
189189
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
190190
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -199,8 +199,8 @@ golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
199199
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
200200
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
201201
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
202-
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
203-
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
202+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
203+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
204204
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
205205
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
206206
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -211,15 +211,15 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
211211
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
212212
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
213213
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
214-
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
215-
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
216-
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
217-
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
214+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
215+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
216+
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
217+
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
218218
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
219219
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
220220
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
221-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
222-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
221+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
222+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
223223
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
224224
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
225225
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

localtests/docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
mysql-primary:
3+
image: $TEST_MYSQL_IMAGE
4+
container_name: mysql-primary
5+
command: --server-id=1 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON
6+
environment:
7+
MYSQL_ROOT_PASSWORD: opensesame
8+
MYSQL_ROOT_HOST: '%'
9+
MYSQL_DATABASE: test
10+
MYSQL_TCP_PORT: 3307
11+
ports:
12+
- '3307:3307'
13+
expose:
14+
- '3307'
15+
mysql-replica:
16+
image: $TEST_MYSQL_IMAGE
17+
container_name: mysql-replica
18+
command: --server-id=2 --log-bin=mysql-bin --binlog-format=row --gtid-mode=ON --enforce-gtid-consistency=ON --log-slave-updates=ON
19+
environment:
20+
MYSQL_ROOT_PASSWORD: opensesame
21+
MYSQL_ROOT_HOST: '%'
22+
MYSQL_DATABASE: test
23+
MYSQL_TCP_PORT: 3308
24+
ports:
25+
- '3308:3308'
26+
expose:
27+
- '3308'

localtests/test.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tests_path=$(dirname $0)
1111
test_logfile=/tmp/gh-ost-test.log
1212
default_ghost_binary=/tmp/gh-ost-test
1313
ghost_binary=""
14+
docker=false
1415
storage_engine=innodb
1516
exec_command_file=/tmp/gh-ost-test.bash
1617
ghost_structure_output_file=/tmp/gh-ost-test.ghost.structure.sql
@@ -25,13 +26,15 @@ replica_port=
2526
original_sql_mode=
2627

2728
OPTIND=1
28-
while getopts "b:s:" OPTION
29+
while getopts "b:s:d" OPTION
2930
do
3031
case $OPTION in
3132
b)
3233
ghost_binary="$OPTARG";;
3334
s)
3435
storage_engine="$OPTARG";;
36+
d)
37+
docker=true;;
3538
esac
3639
done
3740
shift $((OPTIND-1))
@@ -98,6 +101,13 @@ test_single() {
98101
local test_name
99102
test_name="$1"
100103

104+
if [ "$docker" = true ]; then
105+
master_host="0.0.0.0"
106+
master_port="3307"
107+
replica_host="0.0.0.0"
108+
replica_port="3308"
109+
fi
110+
101111
if [ -f $tests_path/$test_name/ignore_versions ] ; then
102112
ignore_versions=$(cat $tests_path/$test_name/ignore_versions)
103113
mysql_version=$(gh-ost-test-mysql-master -s -s -e "select @@version")
@@ -270,9 +280,10 @@ build_binary() {
270280

271281
test_all() {
272282
build_binary
273-
find $tests_path ! -path . -type d -mindepth 1 -maxdepth 1 | cut -d "/" -f 3 | egrep "$test_pattern" | sort | while read test_name ; do
274-
test_single "$test_name"
275-
if [ $? -ne 0 ] ; then
283+
test_dirs=$(find "$tests_path" -mindepth 1 -maxdepth 1 ! -path . -type d | grep "$test_pattern" | sort)
284+
while read -r test_dir; do
285+
test_name=$(basename "$test_dir")
286+
if ! test_single "$test_name" ; then
276287
create_statement=$(gh-ost-test-mysql-replica test -t -e "show create table _gh_ost_test_gho \G")
277288
echo "$create_statement" >> $test_logfile
278289
echo "+ FAIL"
@@ -282,7 +293,7 @@ test_all() {
282293
echo "+ pass"
283294
fi
284295
gh-ost-test-mysql-replica -e "start slave"
285-
done
296+
done <<< "$test_dirs"
286297
}
287298

288299
verify_master_and_replica

script/docker-gh-ost-replica-tests

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
# This script starts two MySQL docker containers in a primary-replica setup
4+
# which can be used for running the replica tests in localtests/ .
5+
# Set the environment var TEST_MYSQL_IMAGE to change the docker image.
6+
#
7+
# Usage:
8+
# docker-gh-ost-replica-tests up start the containers
9+
# docker-gh-ost-replica-tests down remove the containers
10+
# docker-gh-ost-replica-tests run run replica tests on the containers
11+
12+
set -e
13+
14+
GH_OST_ROOT=$(git rev-parse --show-toplevel)
15+
if [[ ":$PATH:" != *":$GH_OST_ROOT:"* ]]; then
16+
export PATH="${PATH}:${GH_OST_ROOT}/script"
17+
fi
18+
19+
poll_mysql() {
20+
CTR=0
21+
cmd="gh-ost-test-mysql-$1"
22+
while ! $cmd -e "select 1;" > /dev/null 2>&1
23+
do
24+
sleep 1
25+
CTR=$((CTR + 1))
26+
if [ $CTR -gt 30 ]; then
27+
echo " ❌ MySQL $1 failed to start"
28+
return 1
29+
fi
30+
done
31+
echo " ✔ MySQL $1 OK"
32+
return 0
33+
}
34+
35+
setup() {
36+
[ -z "$TEST_MYSQL_IMAGE" ] && TEST_MYSQL_IMAGE="mysql:8.0.39"
37+
38+
echo "Starting MySQL $TEST_MYSQL_IMAGE containers..."
39+
compose_file="$GH_OST_ROOT/localtests/docker-compose.yml"
40+
(TEST_MYSQL_IMAGE="$TEST_MYSQL_IMAGE" envsubst < "$compose_file") > "$compose_file.tmp"
41+
docker compose -f "$compose_file.tmp" up -d --wait
42+
43+
echo "Waiting for MySQL..."
44+
poll_mysql "master" || exit 1
45+
poll_mysql "replica" || exit 1
46+
47+
echo -n "Setting up replication..."
48+
gh-ost-test-mysql-master -e "create user if not exists 'repl'@'%' identified with 'mysql_native_password' by 'repl';"
49+
gh-ost-test-mysql-master -e "grant replication slave on *.* to 'repl'@'%'; flush privileges;"
50+
gh-ost-test-mysql-master -e "create user if not exists 'gh-ost'@'%' identified by 'gh-ost';"
51+
gh-ost-test-mysql-master -e "grant all on *.* to 'gh-ost'@'%';"
52+
53+
sleep 1
54+
gh-ost-test-mysql-replica -e "change master to master_host='mysql-primary', master_port=3307, master_user='repl', master_password='repl', master_auto_position=1;"
55+
gh-ost-test-mysql-replica -e "start slave;"
56+
echo "OK"
57+
}
58+
59+
teardown() {
60+
echo "Stopping containers..."
61+
docker stop mysql-replica
62+
docker stop mysql-primary
63+
echo "Removing containers..."
64+
docker rm mysql-replica
65+
docker rm mysql-primary
66+
}
67+
68+
main() {
69+
if [[ "$1" == "up" ]]; then
70+
setup
71+
elif [[ "$1" == "down" ]]; then
72+
teardown
73+
elif [[ "$1" == "run" ]]; then
74+
shift 1
75+
"$GH_OST_ROOT/localtests/test.sh" -d "$@"
76+
fi
77+
}
78+
79+
main "$@"

script/gh-ost-test-mysql-master

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
#
3+
# This executes a command on the mysql-primary docker container created
4+
# from localtests/docker-compose.yml. It's used by localtests/test.sh.
5+
6+
MYSQL_PWD=opensesame mysql -uroot -h0.0.0.0 -P3307 "$@"

script/gh-ost-test-mysql-replica

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
#
3+
# This executes a command on the mysql-replica docker container created
4+
# from localtests/docker-compose.yml. It's used by localtests/test.sh.
5+
6+
MYSQL_PWD=opensesame mysql -uroot -h0.0.0.0 -P3308 "$@"

vendor/golang.org/x/crypto/LICENSE

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/crypto/blowfish/cipher.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)