@@ -24,7 +24,9 @@ store_logs() {
2424 mkdir /home/buildbot/sst_logs/mbackup
2525 for node in 1 2 3; do
2626 for log in prepare move backup; do
27- sudo cp /var/lib/node${node} /mariabackup.${log} .log /home/buildbot/sst_logs/mbackup/node${node} .mariabackup.${log} .log
27+ if [[ -f /var/lib/node${node} /mariabackup.${log} .log ]]; then
28+ sudo cp /var/lib/node${node} /mariabackup.${log} .log /home/buildbot/sst_logs/mbackup/node${node} .mariabackup.${log} .log
29+ fi
2830 done
2931 done
3032 sudo chown -R buildbot:buildbot /home/buildbot/sst_logs
@@ -55,21 +57,31 @@ if [[ $sst_mode == "xtrabackup-v2" ]]; then
5557 esac
5658fi
5759
58- sudo killall mysqld mariadbd || true
60+ # //TEMP probably need to remove mysqld in the future
61+ bb_log_info " make sure mariadb is not running"
62+ for process in mariadbd mysqld; do
63+ if pgrep $process > /dev/null; then
64+ sudo killall $process > /dev/null
65+ fi
66+ done
5967
6068# give mariadb the time to shutdown
6169for i in 1 2 3 4 5 6 7 8 9 10; do
6270 if pgrep ' mysqld|mariadbd' ; then
71+ bb_log_info " give mariadb the time to shutdown ($i )"
6372 sleep 3
6473 else
6574 break
6675 fi
6776done
6877
69- # We don't want crash recovery, but if mysqld hasn't stopped, we'll have to deal with it
70- if pgrep ' mysqld|mariadbd' ; then
71- sudo killall -s 9 mysqld mariadbd
72- fi
78+ # We don't want crash recovery, but if mariadb hasn't stopped, we'll have to
79+ # deal with it
80+ for process in mariadbd mysqld; do
81+ if pgrep $process > /dev/null; then
82+ sudo killall -s 9 $process > /dev/null
83+ fi
84+ done
7385
7486if [[ $sst_mode == " mariabackup" ]]; then
7587 # Starting from 10.3.6, MariaBackup packages have a generic name mariadb-backup.
@@ -198,12 +210,13 @@ res=1
198210set +x
199211bb_log_info " waiting till the first node comes up..."
200212for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
213+ bb_log_info " still waiting for first node comes up ($i )..."
201214 sleep 2
202215 if mysql -uroot -prootpass --port=8301 --protocol=tcp -e " create database mgc; create table mgc.t1 (i int); insert into mgc.t1 values (1)" ; then
203216 res=0
204217 break
205218 fi
206- date " +% H:%M:%S"
219+ date + ' %Y-%m-%dT% H:%M:%S%z '
207220 sudo tail -n 5 /var/lib/node1/node1.err || true
208221done
209222set -x
@@ -212,7 +225,7 @@ if [ "$res" != "0" ]; then
212225 store_logs
213226 exit 1
214227fi
215- mysql -uroot -prootpass --port=8301 --protocol=tcp -e " select * from mgc.t1"
228+ mysql -uroot -prootpass --port=8301 --protocol=tcp -e " select * from mgc.t1\G "
216229
217230# We can't start both nodes at once, because it causes rsync port conflict
218231# (and maybe some other SST methods will have problems too)
@@ -224,23 +237,25 @@ for node in 2 3; do
224237 res=1
225238 set +x
226239 bb_log_info " waiting till node $node comes up..."
227- # shellcheck disable=SC2034
228240 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
229241 sleep 5
230- if mysql -uroot -prootpass --port=830$node --protocol=tcp -e " select * from mgc.t1" ; then
242+ # echoing to 2>/dev/null because we do not want mysql connection error to
243+ # be printed ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost'
244+ if mysql -uroot -prootpass --port=830$node --protocol=tcp -e " select * from mgc.t1\G" 2> /dev/null; then
231245 res=0
232246 break
233247 fi
234- date " +%H:%M:%S"
235- tail -n 5 /var/lib/node${node} /node${node} .err || true
248+ bb_log_info " still waiting for node $node to come up ($i )..."
249+ date +' %Y-%m-%dT%H:%M:%S%z'
250+ sudo tail -n 5 /var/lib/node${node} /node${node} .err || true
236251 done
237252 set -x
238253 if [ " $res " != " 0" ]; then
239254 bb_log_err " failed to start node $node or to connect to it after the start"
240255 store_logs
241256 exit 1
242257 fi
243- mysql -uroot -prootpass --port=830$node --protocol=tcp -e " select * from mgc.t1"
258+ mysql -uroot -prootpass --port=830$node --protocol=tcp -e " select * from mgc.t1\G "
244259done
245260
246261mysql -uroot -prootpass --port=8301 --protocol=tcp -e " show status like 'wsrep_cluster_size'"
@@ -249,13 +264,24 @@ store_logs
249264
250265set -e
251266mysql -uroot -prootpass --port=8301 --protocol=tcp -e " show status like 'wsrep_cluster_size'" | grep 3
252- mysql -uroot -prootpass --port=8302 --protocol=tcp -e " select * from mgc.t1"
253- mysql -uroot -prootpass --port=8303 --protocol=tcp -e " select * from mgc.t1"
267+
268+ for node in 2 3; do
269+ mysql -uroot -prootpass --port=830${node} --protocol=tcp -e " select * from mgc.t1\G"
270+ done
271+
254272mysql -uroot -prootpass --port=8303 --protocol=tcp -e " drop table mgc.t1"
273+ # check that previous drop was replicated to other nodes
274+ for node in 2 1; do
275+ if mysql -uroot -prootpass --port=830${node} --protocol=tcp -e " set wsrep_sync_wait=15; use mgc; show tables" | grep -q t1; then
276+ bb_log_err " modification on node 3 was not replicated on node ${node} "
277+ mysql -uroot -prootpass --port=830${node} --protocol=tcp -e " use mgc; show tables"
278+ exit 1
279+ fi
280+ done
255281
256- # //TEMP I don't understand this test but it's not validated by shellcheck
257- # shellcheck disable=SC2251
258- ! mysql -uroot -prootpass --port=8302 --protocol=tcp -e " set wsrep_sync_wait=15; select * from mgc.t1 "
259- ! mysql -uroot -prootpass --port=8301 --protocol=tcp -e " set wsrep_sync_wait=15; select * from mgc.t1 "
282+ bb_log_info " stop cluster "
283+ sudo killall -s 9 mariadbd || true
284+ sleep 1
285+ sudo killall -s 9 mysqld_safe || true
260286
261287bb_log_ok " all done"
0 commit comments