案例学习-Sysbench压测故障
背景: 故障源于知识星球的一个案例: 我们的数据库需要做在线升级丝滑的验证,所以构造了一个测试环境,客户端Sysbench 用长连接一直打压力,同时Server 端的数据库做在线升级,这个在线升级会让 Server进程重启,所以毫无疑问连接会断开重连,所以期望升级的时候 Sysbench端 QPS 跌0几秒钟然后快速恢复。 但是每次升级都是 Sysbench端 QPS永久跌0,再也不能恢复,所以需要分析为什么,问题出在哪里?有人说是服务端的问题因为只有服务端做了变更 整个测试过程中 Sysbench 是配置的2个连接去压 Server 故障重现: https://articles.zsxq.com/id_zj5qazqa4odz.html 下面也保留一份。 1. 数据库 docker run -it -d --net=host -e MYSQL_ROOT_PASSWORD=123 --name=plantegg mysql 2. 安装依赖包 yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 podman-docker.noarch wireshark sysbench mysql.x86_64 mysql -h127.1 -uroot -p123 3. 生成数据库 mysql -h127.1 -uroot -p123 -e "create database test" 4. 生成测试数据 sysbench --mysql-user='root' --mysql-password='123' --mysql-db='test' --mysql-host='127.0.0.1' --mysql-port='3306' --tables='16' --table-size='10000' --range-size='5' --db-ps-mode='disable' --skip-trx='on' --mysql-ignore-errors='all' --time='1180' --report-interval='1' --histogram='on' --threads=1 oltp_read_only prepare 5. 压测 sysbench --mysql-user='root' --mysql-password='123' --mysql-db='test' --mysql-host='127.0.0.1' --mysql-port='3306' --tables='16' --table-size='10000' --range-size='5' --db-ps-mode='disable' --skip-trx='on' --mysql-ignore-errors='all' --time='1180' --report-interval='1' --histogram='on' --threads=1 oltp_read_only run 6. kill,mysql进程,复现故障 # mysql -h127.1 -uroot -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.3.0 MySQL Community Server - GPL Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> show processlist; +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ | 5 | event_scheduler | localhost | NULL | Daemon | 94 | Waiting on empty queue | NULL | | 13 | root | 127.0.0.1:33492 | test | Sleep | 0 | | NULL | | 14 | root | 127.0.0.1:51398 | NULL | Query | 0 | init | show processlist | +----+-----------------+-----------------+------+---------+------+------------------------+------------------+ MySQL [(none)]> kill 13; Query OK, 0 rows affected (0.000 sec) ...