Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix switchover when many connections appear #132

Merged
merged 5 commits into from
Sep 18, 2024

Conversation

noname0443
Copy link
Collaborator

Pull request description

This PR aims to fix the switchover when a lot of connections try to change data. MySync can't kill them fast enough and fails to complete the switchover.

Please provide steps to reproduce (if it's a bug)

  1. Run the script:
docker rm -f $(docker ps -aq)

cd ../../
GOOS=linux go build -tags netgo,osusergo -o ./tests/images/mysql/mysync ./cmd/mysync/...
docker build --tag=mysync-test-base8.0 tests/images/base --build-arg MYSQL_VERSION=8.0
cd tests/images/
VERSION=8.0 docker-compose up --build -d

docker rm -f images-mysql3-1

docker cp images_zoo1_1:/etc/zk-ssl/ca.cert.pem .
docker cp images_zoo1_1:/etc/zk-ssl/server.crt .
docker cp images_zoo1_1:/etc/zk-ssl/server.key .

docker exec -it images_mysql1_1 mkdir -p /etc/zk-ssl
docker exec -it images_mysql2_1 mkdir -p /etc/zk-ssl

docker cp ca.cert.pem images_mysql1_1:/etc/zk-ssl/
docker cp ca.cert.pem images_mysql2_1:/etc/zk-ssl/

docker cp server.crt images_mysql1_1:/etc/zk-ssl/
docker cp server.crt images_mysql2_1:/etc/zk-ssl/

docker cp server.key images_mysql1_1:/etc/zk-ssl/
docker cp server.key images_mysql2_1:/etc/zk-ssl/

echo "Trying to add mysql1 to mysync..."
while
  timeout -k 70 60 docker exec images_mysql1_1 mysync host add mysql1
  [ $? != 0 ]
do
  echo "Let's try for another time..."
  sleep 2
done

echo "Trying to add mysql2 to mysync..."
while
  timeout -k 70 60 docker exec images_mysql1_1 mysync host add mysql2
  [ $? != 0 ]
do
  echo "Let's try for another time..."
  sleep 2
done

docker exec images_mysql2_1 mysync host add mysql1
docker exec images_mysql2_1 mysync host add mysql2

docker exec images_mysql1_1 mysql -e "CREATE TABLE test1.big_table (id integer, info text);"

docker exec images_mysql1_1 mysql -e "INSERT INTO test1.big_table (id, info) VALUES (1, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');"
for ((a = 0; a < 8; a++)); do
  docker exec images_mysql1_1 mysql -e "INSERT INTO test1.big_table SELECT * FROM test1.big_table;"
done

docker exec images_mysql1_1 mysql -e "CREATE USER user1 IDENTIFIED BY 'password';"
docker exec images_mysql1_1 mysql -e "GRANT ALL ON test1.big_table TO user1;"
  1. Use sysbench with a lot of threads or something like that:
while true; do
  docker exec images_mysql1_1 mysql -u user1 -ppassword -e "INSERT INTO test1.big_table (id, info) VALUES (SLEEP(1), 'aaaaaaaaaaaaa');" &
  sleep 0.01
done
  1. Try to do switchover... It will fall.

internal/app/app.go Outdated Show resolved Hide resolved
internal/config/config.go Outdated Show resolved Hide resolved
@teem0n teem0n merged commit df75a5e into yandex:master Sep 18, 2024
52 checks passed
@noname0443 noname0443 deleted the switchover-on-many-connections branch September 18, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants