Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_stm_000001.test

raw
1 # Requires binlog_format=statement format since query involving
2 # get_lock() is logged in row format if binlog_format=mixed or row.
3 -- source include/have_binlog_format_statement.inc
4 --source include/set_privilege_checks_user_as_system_user.inc
5 -- source include/master-slave.inc
6 -- source include/force_myisam_default.inc
7 -- source include/have_myisam.inc
8
9 CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
10 call mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
11
12 --let $engine_type= myisam
13
14 # Store the time of password_last_changed column from mysql.user table
15 # to restore it back later.
16 let $date_to_restore_root=`SELECT password_last_changed from mysql.user where host='localhost' and user='root'`;
17 let $date_to_restore_sys=`SELECT password_last_changed from mysql.user where host='localhost' and user='mysql.sys'`;
18
19 # Load some data into t1
20 create table t1 (word char(20) not null);
21 load data infile '../../std_data/words.dat' into table t1;
22 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
23 eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
24 select * from t1 limit 10;
25
26 #
27 # Test slave with wrong password
28 #
29 --source include/sync_slave_sql_with_master.inc
30 stop slave;
31 connection master;
32 set password for root@"localhost" = 'foo';
33 connection slave;
34 start slave;
35 connection master;
36 #
37 # Give slave time to do at last one failed connect retry
38 # This one must be short so that the slave will not stop retrying
39 sleep 2;
40 set password for root@"localhost" = '';
41 # Give slave time to connect (will retry every second)
42 sleep 2;
43
44 create table t3(n int);
45 insert into t3 values(1),(2);
46 --source include/sync_slave_sql_with_master.inc
47 select * from t3;
48 select sum(length(word)) from t1;
49 connection master;
50 drop table t1,t3;
51 --source include/sync_slave_sql_with_master.inc
52
53 # Test if the slave SQL thread can be more than 16K behind the slave
54 # I/O thread (> IO_SIZE)
55
56 connection master;
57 # we'll use table-level locking to delay slave SQL thread
58 eval create table t1 (n int) engine=$engine_type;
59 --source include/sync_slave_sql_with_master.inc
60 connection master;
61 reset master;
62 connection slave;
63 stop slave;
64 reset slave;
65
66 connection master;
67 let $1=100;
68 # Generate 16K of relay log
69 --let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
70 disable_query_log;
71 while ($1)
72 {
73 eval insert into t1 values($1);
74 dec $1;
75 }
76 enable_query_log;
77
78 --let $assert_text= We should have generated greater than 16 KB relay log
79 --let $assert_cond= [SHOW MASTER STATUS, Position, 1] - $pos > 16384
80 --source include/assert.inc
81
82 # Try to cause a large relay log lag on the slave by locking t1
83 connection slave;
84 lock tables t1 read;
85 start slave;
86 connection master;
87 --source include/sync_slave_io_with_master.inc
88 unlock tables;
89
90 #test handling of aborted connection in the middle of update
91
92 connection master;
93 create table t2(id int);
94 insert into t2 values(connection_id());
95
96 connection master1;
97 # Avoid generating result
98 create temporary table t3(n int);
99 --disable_warnings
100 insert into t3 select get_lock('crash_lock%20C', 1) from t2;
101 --enable_warnings
102
103 connection master;
104 send update t1 set n = n + if(n > 50, 1, get_lock('crash_lock%20C', 100));
105 connection master1;
106 let $wait_condition=
107 select count(*) > 0 from information_schema.processlist
108 where state = "User lock" and info like "update t1%";
109 --source include/wait_condition.inc
110 select (@id := id) - id from t2;
111 kill @id;
112 drop table t2;
113 drop temporary table if exists t3;
114 connection master;
115 # The get_lock function causes warning for unsafe statement.
116 --disable_warnings
117 --error 1317,2013
118 reap;
119 --enable_warnings
120 connection slave;
121 # The SQL slave thread should now have stopped because the query was killed on
122 # the master (so it has a non-zero error code in the binlog).
123 # The slave should report ER_ERROR_ON_SOURCE and the error message should
124 # contain the actual error code received from master 1053 = ER_SERVER_SHUTDOWN
125 --let $slave_sql_errno= convert_error(ER_ERROR_ON_SOURCE)
126 ###--source include/wait_for_slave_sql_error_and_skip.inc
127 --source include/wait_for_slave_sql_error.inc
128 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=1;
129 source include/start_slave.inc;
130
131 select count(*) from t1;
132 connection master1;
133 drop table t1;
134 create table t1 (n int);
135 insert into t1 values(3456);
136 create user 'blafasel2'@'10.10.10.%' identified by 'blafasel2';
137 select select_priv,user from mysql.user where user = _binary'blafasel2';
138 update mysql.user set Select_priv = "Y" where User= _binary"blafasel2";
139 select select_priv,user from mysql.user where user = _binary'blafasel2';
140 --source include/sync_slave_sql_with_master.inc
141 select n from t1;
142 select select_priv,user from mysql.user where user = _binary'blafasel2';
143 connection master1;
144 drop table t1;
145 delete from mysql.user where user="blafasel2";
146
147 --disable_query_log ONCE
148 --eval UPDATE mysql.user SET password_last_changed = '$date_to_restore_root' WHERE user='root'
149 --disable_query_log ONCE
150 --eval UPDATE mysql.user SET password_last_changed = '$date_to_restore_sys' WHERE user='mysql.sys'
151 --echo # mysql.user table restored to original values.
152
153 --source include/sync_slave_sql_with_master.inc
154
155 # End of 4.1 tests
156 --source include/rpl_end.inc