| 1 |
############################################################################### |
| 2 |
# # |
| 3 |
# Variable Name: init_slave # |
| 4 |
# Scope: GLOBAL # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: string # |
| 7 |
# Default Value: # |
| 8 |
# Range: # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-08 # |
| 12 |
# Author: Rizwan # |
| 13 |
# Modified: HHunger 2008-09-29 Fixed the bug by inserting the usual wait and # |
| 14 |
# SQL-Satements to control master and slave, # |
| 15 |
# deleted the sleep and made improvements like: # |
| 16 |
# - Replaced the opt file by dynamic variables, # |
| 17 |
# - Made the tests independant of the initial # |
| 18 |
# values of the global variables, # |
| 19 |
# - Reduced the test to the needed test case to # |
| 20 |
# save run time, # |
| 21 |
# - Beautification. # |
| 22 |
# # |
| 23 |
# Description: Test Cases of Dynamic System Variable init_slave # |
| 24 |
# that checks the behavior of this variable # |
| 25 |
# # |
| 26 |
# Reference: # |
| 27 |
# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # |
| 28 |
# # |
| 29 |
############################################################################### |
| 30 |
|
| 31 |
source include/master-slave.inc; |
| 32 |
|
| 33 |
# Since a part of slave SQL thread initialisation happens after Slave_SQL_Running |
| 34 |
# has been set to Yes, there is a race condition between initialisation above and |
| 35 |
# init_slave setting given below. Synchronise slave applier with master to ensure |
| 36 |
# init_slave is complete and applier had processed few events like FD. |
| 37 |
--source include/sync_slave_sql_with_master.inc |
| 38 |
|
| 39 |
--disable_query_log |
| 40 |
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 41 |
--enable_query_log |
| 42 |
# |
| 43 |
# save the current values |
| 44 |
|
| 45 |
SET @start_max_connections= @@global.max_connections; |
| 46 |
SET @start_init_slave= @@global.init_slave; |
| 47 |
|
| 48 |
# setting of a global value with an effect on the next start of the slave server |
| 49 |
# check that @@global.init_slave could be set |
| 50 |
SET NAMES utf8; |
| 51 |
let $my_init_slave= |
| 52 |
'SET @@global.max_connections = @@global.max_connections + 1 -- комментарий'; |
| 53 |
eval SET @@global.init_slave = $my_init_slave; |
| 54 |
|
| 55 |
# show the data type of the variable |
| 56 |
--disable_warnings |
| 57 |
DROP TABLE IF EXISTS t1; |
| 58 |
CREATE TEMPORARY TABLE t1 AS SELECT @@global.init_slave AS my_column; |
| 59 |
--enable_warnings |
| 60 |
DESCRIBE t1; |
| 61 |
select length(my_column) from t1; |
| 62 |
DROP TABLE t1; |
| 63 |
# |
| 64 |
# check that the new setting of @@global.init_slave becomes immediately visible |
| 65 |
eval SELECT @@global.init_slave = $my_init_slave; |
| 66 |
--echo Expect 1 |
| 67 |
# wait for the slave threads have set the global variable. |
| 68 |
let $wait_timeout= 90; |
| 69 |
let $wait_condition= SELECT @@global.max_connections = @start_max_connections; |
| 70 |
--source include/wait_condition_sp.inc |
| 71 |
# check that the action in init_slave does not happen immediately |
| 72 |
--let $assert_text= @@global.max_connections = @start_max_connections |
| 73 |
--let $assert_cond= @@global.max_connections = @start_max_connections |
| 74 |
--source include/assert.inc |
| 75 |
|
| 76 |
--source include/restart_slave_sql.inc |
| 77 |
|
| 78 |
# Upon slave start, sync the applier with master, to ensure slave has |
| 79 |
# completed init_slave command execution and processed FD event from the |
| 80 |
# master. |
| 81 |
--connection master |
| 82 |
--source include/sync_slave_sql_with_master.inc |
| 83 |
|
| 84 |
# |
| 85 |
# wait for the slave threads have set the global variable. |
| 86 |
let $wait_timeout= 90; |
| 87 |
let $wait_condition= SELECT @@global.max_connections = @start_max_connections + 1; |
| 88 |
--source include/wait_condition_sp.inc |
| 89 |
# check that the action in init_slave was executed and had the intended effect |
| 90 |
--let $assert_text= @@global.max_connections = @start_max_connections + 1 |
| 91 |
--let $assert_cond= @@global.max_connections = @start_max_connections + 1 |
| 92 |
--source include/assert.inc |
| 93 |
# |
| 94 |
# Setting a variable(which is local to a session) and must not be visible |
| 95 |
SET @@global.init_slave = "SET @a=5"; |
| 96 |
# |
| 97 |
--source include/restart_slave_sql.inc |
| 98 |
# |
| 99 |
SHOW VARIABLES LIKE 'init_slave'; |
| 100 |
# expect NULL |
| 101 |
SELECT @a; |
| 102 |
--echo Expect NULL |
| 103 |
# |
| 104 |
# Clean up |
| 105 |
SET @@global.max_connections= @start_max_connections; |
| 106 |
SET @@global.init_slave= @start_init_slave; |
| 107 |
################################################## |
| 108 |
# End of functionality Testing for init_slave # |
| 109 |
################################################## |
| 110 |
|
| 111 |
--source include/rpl_end.inc |