summaryrefslogtreecommitdiff
path: root/mysql-test/t/thread_cache_size_func.test
blob: 9f2eb906f52ab7dbafe870258c453428bf6dcc80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
############# mysql-test\t\thread_cache_size_func.test #######################################
#                                                                                       #
# Variable Name: thread_cache_size                                                      #
# Scope: SESSION                                                                        #
# Access Type: Dynamic                                                                  #
# Data Type: Enumeration                                                                #
# Default Value: 0                                                                      #
# Values:      0-16384                                                                  #
#                                                                                       #
#                                                                                       #
# Creation Date: 2008-03-02                                                             #
# Author:  Sharique Abdullah                                                                #
#                                                                                       #
# Description: Test Cases of Dynamic System Variable "thread_cache_size"                #
#              that checks behavior of this variable in the following ways              #
#              * Functionality based on different values                                #
#                                                                                       #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html        #
# option_mysqld_thread_cache_size                                                       #
#                                                                                       #
#########################################################################################



#
# Setup
#

SET @global_thread_cache_size = @@GLOBAL.thread_cache_size;

FLUSH STATUS;

#
# Greater than cache threads, setting cache size to 3
#
-- ECHO '# Test1#'
SET @@GLOBAL.thread_cache_size=3;

let $threadsCreated1 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);
--echo Saving threads cached, threads created values

SHOW STATUS LIKE 'Threads_cached';
--echo 0 Expected

--ECHO '#Old value for thread_cache'#

##################################
# Make 4 connections             #
##################################

--echo ** Connecting conn1 using username 'root' **
connect (conn1,localhost,root,,);
--echo ** Connecting conn2 using username 'root' **
connect (conn2,localhost,root,,);
--echo ** Connecting conn3 using username 'root' **
connect (conn3,localhost,root,,);
--echo ** Connecting conn4 using username 'root' **
connect (conn4,localhost,root,,);

let $threadsCreated2 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);
--echo Saving threads cached, threads created values

--disable_query_log
eval SELECT ($threadsCreated2 - $threadsCreated1) AS 'Threads Created Difference';
--enable_query_log

--echo 4 Expected
SHOW STATUS LIKE 'Threads_cached';
--echo 0 Expected

####################################
#Disconnecting all the connections #
####################################

--echo ** Connection default **
connection default;

--echo ** Disconnecting conn1,conn2,conn3,conn4 **
disconnect conn1;
disconnect conn2;
disconnect conn3;
disconnect conn4;

#
# Checking the status
#

--echo '#new  values for thread cache after disconnecting'#
let $threadsCreated3 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);

--echo Saving threads cached, threads created values
--disable_query_log
eval SELECT ($threadsCreated3 - $threadsCreated2) AS 'Threads Created Difference';
--enable_query_log
--echo 0 Expected
SHOW STATUS LIKE 'Threads_cached';
--echo 3 Expected


#
# Decreasing cache size to 1
#
SET @@GLOBAL.thread_cache_size=1;

connection default;

let $threadsCreated6 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);
--echo Saving threads cached, threads created values
--disable_query_log
eval SELECT $threadsCreated6 - $threadsCreated3 AS 'Threads Created Difference';
--enable_query_log
--echo 0 Expected
SHOW STATUS LIKE 'Threads_cached';
--echo 1 Expected
--echo Bug: The number of threads cached should have decreased with cache size decrease.

--echo ** Connecting conn1 using username 'root' **
CONNECT (conn1,localhost,root,,);
--echo ** Connecting conn2 using username 'root' **
CONNECT (conn2,localhost,root,,);

let $threadsCreated4 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);
--echo Saving threads cached, threads created values
--disable_query_log
eval SELECT $threadsCreated4 - $threadsCreated3 AS 'Threads Created Difference';
--enable_query_log
--echo 1 Expected
--echo Bug: The number of threads created should have increased because the cache should have 1 thread only
SHOW STATUS LIKE 'Threads_cached';
--echo 0 Expected
--echo Bug: The number of threads created should have decreased because atleast 1 new connection came in

--echo ** Connection default **
connection default;

--echo ** Disconnecting conn1,conn2 **
disconnect conn1;
disconnect conn2;

--ECHO '#new status values for thread cache'#
let $threadsCreated5 = query_get_value(SHOW STATUS LIKE 'Threads_created', Value, 1);
--echo Saving threads cached, threads created values
--disable_query_log
eval SELECT ($threadsCreated5 - $threadsCreated4) AS 'Threads Created Difference';
--enable_query_log
--echo 0 Expected
SHOW STATUS LIKE 'Threads_cached';
--echo 1 Expected

--echo Saving threads cached, threads created values

#
# Cleanup
#

SET @@GLOBAL.thread_cache_size = @global_thread_cache_size;