Skip to content

Commit b41c649

Browse files
author
Mohit Joshi
committed
Bug#27555916 - EVALUATE SET PERSIST COMPATIBILITY WITH ALL THE SERVER VARIABLES
Description : ============ It is seen that there are multiple bugs reported for SET PERSIST usage with server variables. Hence, objective of filing this bug is to test SET PERSIST with the server variables and evaluate that the behaviour is expected. During the course of testing SET PERSIST option, all the bugs found will be reported and in the end an automated MTR test will be written and pushed. Reviewed by: Anitha Gopi <anitha.gopi@oracle.com> Bharathy Satish <bharathy.x.satish@oracle.com>
1 parent 0f14e4c commit b41c649

5 files changed

+360
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
########################################################################
2+
# Run only on debug build,non-windows as few server variables are not
3+
# available on all platforms.
4+
########################################################################
5+
##############################################################
6+
# 0. Verify that variables present in performance_schema.global
7+
# variables are actually global variables and can be set using
8+
# SET GLOBAL
9+
###############################################################
10+
CREATE TABLE global_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
11+
INSERT INTO global_vars (var_name, var_value) SELECT * FROM
12+
performance_schema.global_variables WHERE variable_name NOT IN
13+
('innodb_monitor_enable',
14+
'innodb_monitor_disable',
15+
'innodb_monitor_reset',
16+
'innodb_monitor_reset_all',
17+
'rbr_exec_mode');
18+
############################################################
19+
# 1. Check that there are no persisted variable settings.
20+
############################################################
21+
include/assert.inc ['Expect 0 persisted variables.']
22+
23+
############################################################
24+
# 2. Initialization. Test SET PERSIST. Verify persisted
25+
# variables.
26+
############################################################
27+
CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
28+
INSERT INTO all_vars (var_name, var_value)
29+
SELECT * FROM performance_schema.global_variables
30+
WHERE variable_name NOT IN
31+
('keyring_operations',
32+
'mandatory_roles',
33+
'innodb_ft_aux_table',
34+
'innodb_ft_user_stopword_table',
35+
'innodb_tmpdir',
36+
'innodb_ft_server_stopword_table',
37+
'rbr_exec_mode',
38+
'log_syslog',
39+
'log_syslog_facility',
40+
'log_syslog_include_pid',
41+
'log_syslog_tag')
42+
ORDER BY variable_name;
43+
44+
include/assert.inc ['Expect 557 variables in the table. Due to open Bugs, we are checking for 546']
45+
46+
# Test SET PERSIST
47+
48+
include/assert.inc ['Expect 354 persisted variables in the table. Due to open Bugs, we are checking for 349']
49+
50+
############################################################
51+
# 3. Restart server, it must preserve the persisted variable
52+
# settings. Verify persisted configuration.
53+
############################################################
54+
# restart
55+
56+
include/assert.inc ['Expect 349 persisted variables in persisted_variables table.']
57+
include/assert.inc ['Expect 349 persisted variables shown as PERSISTED in variables_info table.']
58+
59+
############################################################
60+
# 4. Test RESET PERSIST IF EXISTS. Verify persisted variable
61+
# settings are removed.
62+
############################################################
63+
64+
include/assert.inc ['Expect 0 persisted variables.']
65+
66+
############################################################
67+
# 5. Clean up.
68+
############################################################
69+
DROP TABLE all_vars;
70+
DROP TABLE global_vars;
71+
# restart

mysql-test/r/variables.result

+31
Original file line numberDiff line numberDiff line change
@@ -1978,3 +1978,34 @@ End of 5.1 tests
19781978
SHOW VARIABLES like 'slave_skip_errors';
19791979
Variable_name Value
19801980
slave_skip_errors OFF
1981+
SET @sql_big_selects_save=@@sql_big_selects;
1982+
SET @@sql_big_selects=1;
1983+
CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
1984+
INSERT INTO all_vars (var_name, var_value)
1985+
SELECT a.variable_name,a.variable_value
1986+
FROM performance_schema.session_variables a
1987+
LEFT JOIN performance_schema.global_variables b
1988+
ON a.variable_name=b.variable_name
1989+
WHERE b.variable_name IS NULL
1990+
AND a.variable_name NOT IN ('debug_sync');
1991+
SET SESSION error_count = @@session.error_count;
1992+
SET SESSION external_user = @@session.external_user;
1993+
SET SESSION gtid_next = @@session.gtid_next;
1994+
SET SESSION identity = @@session.identity;
1995+
SET SESSION insert_id = @@session.insert_id;
1996+
SET SESSION last_insert_id = @@session.last_insert_id;
1997+
SET SESSION original_commit_timestamp = @@session.original_commit_timestamp;
1998+
SET SESSION proxy_user = @@session.proxy_user;
1999+
SET SESSION pseudo_slave_mode = @@session.pseudo_slave_mode;
2000+
Warnings:
2001+
Warning 1231 'pseudo_slave_mode' change was ineffective.
2002+
SET SESSION pseudo_thread_id = @@session.pseudo_thread_id;
2003+
SET SESSION rand_seed1 = @@session.rand_seed1;
2004+
SET SESSION rand_seed2 = @@session.rand_seed2;
2005+
SET SESSION resultset_metadata = @@session.resultset_metadata;
2006+
SET SESSION sql_log_bin = @@session.sql_log_bin;
2007+
SET SESSION timestamp = @@session.timestamp;
2008+
SET SESSION transaction_allow_batching = @@session.transaction_allow_batching;
2009+
SET SESSION warning_count = @@session.warning_count;
2010+
SET @@sql_big_selects=@sql_big_selects_save;
2011+
DROP TABLE all_vars;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--mysqlx=ON
+227
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
################################################################################
2+
#
3+
# Creation Date: 19-Feb-2018
4+
# Test Author: Mohit Joshi
5+
#
6+
# The aim of this testcase is to test persisted behavior of all system
7+
# variables with SET PERSIST and RESET PERSIST IF EXISTS clauses.
8+
#
9+
# Test:
10+
# 0. SET PERSIST is applicable on GLOBAL,dynamic variables only. Hence, verify
11+
# that variables in performance_schema.global_variables are actually
12+
# settable with SET GLOBAL.
13+
# 1. Check that there are no persisted variable settings due to improper
14+
# cleanup by other testcases.
15+
# 2. Test SET PERSIST. Verify persisted variables.
16+
# 3. Restart server, it must preserve the persisted variable settings.
17+
# Verify persisted configuration.
18+
# 4. Test RESET PERSIST IF EXISTS. Verify persisted variable settings are
19+
# removed.
20+
# 5. Clean up.
21+
22+
# Note - Currently there are 557 global variables
23+
# -> SELECT COUNT(*) FROM performance_schema.global_variables
24+
# In future, if a new global variable is added, it will be automatically
25+
# picked up from performance_schema.global_variables table.
26+
#
27+
# Out of all, 354 are global persistent variable. In future, if a new global
28+
# persistent variable is added, it is the responsibility of the Dev to
29+
# edit this variable.
30+
# -> $total_persistent_var=354
31+
################################################################################
32+
33+
--echo ########################################################################
34+
--echo # Run only on debug build,non-windows as few server variables are not
35+
--echo # available on all platforms.
36+
--echo ########################################################################
37+
--source include/have_debug.inc
38+
--source include/not_windows.inc
39+
40+
let $total_global_vars=`SELECT COUNT(*) FROM performance_schema.global_variables`;
41+
let $total_persistent_vars=354;
42+
43+
--echo ##############################################################
44+
--echo # 0. Verify that variables present in performance_schema.global
45+
--echo # variables are actually global variables and can be set using
46+
--echo # SET GLOBAL
47+
--echo ###############################################################
48+
49+
CREATE TABLE global_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
50+
51+
# Following variables cannot be set in this format:
52+
# -> SET GLOBAL innodb_monitor_enable = @@global.innodb_monitor_enable
53+
# ERROR 1231 (42000): Variable 'innodb_monitor_enable' can't be set to the value of 'NULL'
54+
# -> SET GLOBAL innodb_monitor_disable = @@global.innodb_monitor_disable;
55+
# ERROR 1231 (42000): Variable 'innodb_monitor_disable' can't be set to the value of 'NULL'
56+
# -> SET GLOBAL innodb_monitor_reset = @@global.innodb_monitor_reset;
57+
# ERROR 1231 (42000): Variable 'innodb_monitor_reset' can't be set to the value of 'NULL'
58+
# -> SET GLOBAL innodb_monitor_reset_all = @@global.innodb_monitor_reset_all;
59+
# ERROR 1231 (42000): Variable 'innodb_monitor_reset_all' can't be set to the value of 'NULL'
60+
61+
# Bug#27534122 - RBR_EXEC_MODE DOES NOT SUPPORT GLOBAL SCOPE
62+
INSERT INTO global_vars (var_name, var_value) SELECT * FROM
63+
performance_schema.global_variables WHERE variable_name NOT IN
64+
('innodb_monitor_enable',
65+
'innodb_monitor_disable',
66+
'innodb_monitor_reset',
67+
'innodb_monitor_reset_all',
68+
'rbr_exec_mode');
69+
70+
--let $count_vars= `SELECT COUNT(*) FROM global_vars;`
71+
--let $var_id=1
72+
--disable_query_log
73+
--disable_warnings
74+
75+
while($var_id <= $count_vars)
76+
{
77+
--let $var_name= `SELECT var_name FROM global_vars WHERE id=$var_id;`
78+
--error 0,ER_INCORRECT_GLOBAL_LOCAL_VAR,ER_WRONG_ARGUMENTS
79+
--eval SET GLOBAL $var_name = @@global.$var_name
80+
--inc $var_id
81+
}
82+
83+
--enable_warnings
84+
--enable_query_log
85+
86+
--echo ############################################################
87+
--echo # 1. Check that there are no persisted variable settings.
88+
--echo ############################################################
89+
90+
--let $assert_text= 'Expect 0 persisted variables.'
91+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0
92+
--source include/assert.inc
93+
94+
--echo
95+
--echo ############################################################
96+
--echo # 2. Initialization. Test SET PERSIST. Verify persisted
97+
--echo # variables.
98+
--echo ############################################################
99+
100+
--let $MYSQLD_DATADIR= `select @@datadir;`
101+
102+
CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
103+
104+
# Currently we are not able to test the below 11 global variables because of
105+
# open bugs (listed below). Once the bugs are fixed,
106+
# below query must be modified.
107+
#
108+
# Bug#27512616 - SET PERSIST COMMAND FAILS TO MAP DEFAULT(NULL) VALUES IN MYSQLD-AUTO.CNF
109+
# Bug#27523095 - SET PERSIST MANDATORY_ROLES FAILS TO START THE SERVER
110+
# Bug#27534122 - RBR_EXEC_MODE DOES NOT SUPPORT GLOBAL SCOPE
111+
# Bug#27534041 - SET GLOBAL INNODB_MONITOR_ENABLE CAUSES SERVER TO CRASH
112+
# Bug#27534089 - LOG_SYS_* GLOBAL VARIABLES DO NOT WORK WITH SET GLOBAL/PERSIST
113+
114+
INSERT INTO all_vars (var_name, var_value)
115+
SELECT * FROM performance_schema.global_variables
116+
WHERE variable_name NOT IN
117+
('keyring_operations',
118+
'mandatory_roles',
119+
'innodb_ft_aux_table',
120+
'innodb_ft_user_stopword_table',
121+
'innodb_tmpdir',
122+
'innodb_ft_server_stopword_table',
123+
'rbr_exec_mode',
124+
'log_syslog',
125+
'log_syslog_facility',
126+
'log_syslog_include_pid',
127+
'log_syslog_tag')
128+
ORDER BY variable_name;
129+
130+
--let $count_vars= `SELECT COUNT(*) FROM all_vars;`
131+
--echo
132+
--let $assert_text= 'Expect 557 variables in the table. Due to open Bugs, we are checking for 546'
133+
--let $assert_cond= [SELECT COUNT(*) as count FROM all_vars, count, 1] = $total_global_vars-11
134+
--source include/assert.inc
135+
136+
--echo
137+
--echo # Test SET PERSIST
138+
--let $var_id=1
139+
--disable_query_log
140+
--disable_warnings
141+
while($var_id <= $count_vars)
142+
{
143+
--let $var_names= `SELECT var_name FROM all_vars WHERE id=$var_id;`
144+
--error 0,ER_INCORRECT_GLOBAL_LOCAL_VAR,ER_WRONG_VALUE_FOR_VAR
145+
--eval SET PERSIST $var_names = @@GLOBAL.$var_names
146+
--inc $var_id
147+
}
148+
# Below 4 tests have default value as "" and these variables can't be set to
149+
# empty value. Hence, setting them seperately.
150+
SET PERSIST innodb_monitor_enable= "latch";
151+
SET PERSIST innodb_monitor_disable="latch";
152+
SET PERSIST innodb_monitor_reset="latch";
153+
SET PERSIST innodb_monitor_reset_all="latch";
154+
155+
--enable_warnings
156+
--enable_query_log
157+
--echo
158+
--let $assert_text= 'Expect 354 persisted variables in the table. Due to open Bugs, we are checking for 349'
159+
160+
# Below are the persisted variables we are unable to test at the moment due to
161+
# existing Bugs.
162+
# 1. keyring_operations (Bug#27523095)
163+
# 2. mandatory_roles (Bug#27523095)
164+
# 3. innodb_ft_aux_table (Bug#27512616)
165+
# 4. innodb_ft_user_stopword_table (Bug#27512616)
166+
# 5. innodb_ft_server_stopword_table (Bug#27512616)
167+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $total_persistent_vars-5
168+
--source include/assert.inc
169+
170+
--echo
171+
--echo ############################################################
172+
--echo # 3. Restart server, it must preserve the persisted variable
173+
--echo # settings. Verify persisted configuration.
174+
--echo ############################################################
175+
176+
--source include/restart_mysqld.inc
177+
--source include/wait_until_connected_again.inc
178+
179+
--echo
180+
--let $assert_text= 'Expect 349 persisted variables in persisted_variables table.'
181+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = $total_persistent_vars-5
182+
--source include/assert.inc
183+
184+
--let $assert_text= 'Expect 349 persisted variables shown as PERSISTED in variables_info table.'
185+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info WHERE variable_source="PERSISTED", count, 1] = $total_persistent_vars-5
186+
--source include/assert.inc
187+
188+
--let $assert_text= 'Expect 349 persisted variables with matching peristed and global values.'
189+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.variables_info vi JOIN performance_schema.persisted_variables pv JOIN performance_schema.global_variables gv ON vi.variable_name=pv.variable_name AND vi.variable_name=gv.variable_name AND pv.variable_value=gv.variable_value WHERE vi.variable_source="PERSISTED", count, 1] = $total_persistent_vars-5
190+
191+
--echo
192+
--echo ############################################################
193+
--echo # 4. Test RESET PERSIST IF EXISTS. Verify persisted variable
194+
--echo # settings are removed.
195+
--echo ############################################################
196+
197+
--disable_query_log
198+
--disable_warnings
199+
--let $var_id=1
200+
while ( $var_id <= $count_vars )
201+
{
202+
--let $var_names= `SELECT var_name FROM all_vars WHERE id=$var_id`
203+
--eval RESET PERSIST IF EXISTS $var_names
204+
--inc $var_id
205+
}
206+
--enable_query_log
207+
--enable_warnings
208+
209+
--echo
210+
--let $assert_text= 'Expect 0 persisted variables.'
211+
--let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.persisted_variables, count, 1] = 0
212+
--source include/assert.inc
213+
214+
--echo
215+
--echo ############################################################
216+
--echo # 5. Clean up.
217+
--echo ############################################################
218+
219+
--let $count_vars=
220+
--let $var_id=
221+
--let $var_names=
222+
--remove_file $MYSQLD_DATADIR/mysqld-auto.cnf
223+
DROP TABLE all_vars;
224+
DROP TABLE global_vars;
225+
# Restart
226+
--let restart_parameters=
227+
--source include/restart_mysqld.inc

mysql-test/t/variables.test

+30
Original file line numberDiff line numberDiff line change
@@ -1817,3 +1817,33 @@ DROP TABLE t1;
18171817
#
18181818

18191819
SHOW VARIABLES like 'slave_skip_errors';
1820+
1821+
#
1822+
# Verify that SESSION only variables present in performance_schema.session_variables
1823+
# are actually settable using SET SESSION
1824+
#
1825+
SET @sql_big_selects_save=@@sql_big_selects;
1826+
SET @@sql_big_selects=1;
1827+
CREATE TABLE all_vars (id INT PRIMARY KEY AUTO_INCREMENT, var_name VARCHAR(64), var_value VARCHAR(1024));
1828+
1829+
INSERT INTO all_vars (var_name, var_value)
1830+
SELECT a.variable_name,a.variable_value
1831+
FROM performance_schema.session_variables a
1832+
LEFT JOIN performance_schema.global_variables b
1833+
ON a.variable_name=b.variable_name
1834+
WHERE b.variable_name IS NULL
1835+
AND a.variable_name NOT IN ('debug_sync');
1836+
1837+
--let $count_vars= `SELECT COUNT(*) FROM all_vars;`
1838+
--let $var_id=1
1839+
while($var_id <= $count_vars)
1840+
{
1841+
--let $var_name= `SELECT var_name FROM all_vars WHERE id=$var_id;`
1842+
--error 0,ER_INCORRECT_GLOBAL_LOCAL_VAR
1843+
--eval SET SESSION $var_name = @@session.$var_name
1844+
--inc $var_id
1845+
}
1846+
1847+
#Cleanup
1848+
SET @@sql_big_selects=@sql_big_selects_save;
1849+
DROP TABLE all_vars;

0 commit comments

Comments
 (0)