Merge lp:~vlad-lesin/percona-server/issue-21170-ssl_connections_counting into lp:percona-server/5.5

Proposed by Vlad Lesin
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 242
Proposed branch: lp:~vlad-lesin/percona-server/issue-21170-ssl_connections_counting
Merge into: lp:percona-server/5.5
Diff against target: 295 lines (+127/-3)
8 files modified
Percona-Server/mysql-test/r/percona_ssl_connections_count.result (+21/-0)
Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result (+3/-0)
Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test (+3/-0)
Percona-Server/mysql-test/t/percona_ssl_connections_count.test (+79/-0)
Percona-Server/sql/sql_connect.cc (+10/-2)
Percona-Server/sql/sql_show.cc (+6/-1)
Percona-Server/sql/sql_yacc.yy (+1/-0)
Percona-Server/sql/structs.h (+4/-0)
To merge this branch: bzr merge lp:~vlad-lesin/percona-server/issue-21170-ssl_connections_counting
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+105612@code.launchpad.net

Description of the change

Issue 21770:

CLIENT_STATISTICS, THREAD_STATISTICS, and USER_STATISTICS should also have a column TOTAL_CONNECTIONS_SSL to distinguish between these two types of connections. This will help us to better track any users that are connecting to the db servers without SSL.

http://jenkins.percona.com/view/Percona%20Server%205.5/job/percona-server-5.5-param/363/
http://jenkins.percona.com/view/Percona%20Server%205.5/job/percona-server-5.5-vlesin/1/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

   - please create a blueprint on Launchpad for this task, so we can
     track it, target to milestones, document, etc. You can then
     reference this MP in the revision comment (rather than the issue #)

   - bug #997036 is a one-line fix, so let's fix it in the same worklog
     rather than add workarounds for it in the test?

   - I don't see any problems with having TOTAL_SSL_CONNECTIONS as the
     last field in the corresponding tables, so you don't have to shift
     other fields and change unrelated lines of code, thus increasing
     the chance of merge conflicts when merging other fixes from 5.1,
     for example.

> +SET GLOBAL `userstat`= default;
> +SET GLOBAL `thread_statistics`= default;

   - please save values to e.g. old_userstat and old_thread_statistics
     and then restore them instead of using the default value. Using the
     default will fail when you want to run the test suite with
     non-standard options, e.g. with --mysqld=--userstat for example. In
     such case, the default value will be different from what the
     variable had on startup.

review: Needs Fixing
Revision history for this message
Vlad Lesin (vlad-lesin) wrote :

>
> - please create a blueprint on Launchpad for this task, so we can
> track it, target to milestones, document, etc. You can then
> reference this MP in the revision comment (rather than the issue #)
>
> - bug #997036 is a one-line fix, so let's fix it in the same worklog
> rather than add workarounds for it in the test?
>
> - I don't see any problems with having TOTAL_SSL_CONNECTIONS as the
> last field in the corresponding tables, so you don't have to shift
> other fields and change unrelated lines of code, thus increasing
> the chance of merge conflicts when merging other fixes from 5.1,
> for example.
>
> > +SET GLOBAL `userstat`= default;
> > +SET GLOBAL `thread_statistics`= default;
>
> - please save values to e.g. old_userstat and old_thread_statistics
> and then restore them instead of using the default value. Using the
> default will fail when you want to run the test suite with
> non-standard options, e.g. with --mysqld=--userstat for example. In
> such case, the default value will be different from what the
> variable had on startup.

Done.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Approved after merging 2 separate revisions into one.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/r/percona_ssl_connections_count.result'
2--- Percona-Server/mysql-test/r/percona_ssl_connections_count.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_ssl_connections_count.result 2012-05-14 14:38:21 +0000
4@@ -0,0 +1,21 @@
5+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
6+INFORMATION_SCHEMA.USER_STATISTICS ORDER BY USER;
7+TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
8+1 0
9+2 1
10+2 1
11+2 1
12+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
13+INFORMATION_SCHEMA.CLIENT_STATISTICS;
14+TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
15+7 3
16+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
17+INFORMATION_SCHEMA.THREAD_STATISTICS ORDER BY THREAD_ID;
18+TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
19+1 0
20+1 1
21+1 0
22+1 1
23+1 0
24+1 1
25+1 0
26
27=== modified file 'Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result'
28--- Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result 2012-04-18 23:26:11 +0000
29+++ Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result 2012-05-14 14:38:21 +0000
30@@ -1,3 +1,6 @@
31 SELECT @@global.thread_statistics;
32 @@global.thread_statistics
33 0
34+SET @old_thread_statistics= @@global.thread_statistics;
35+SET GLOBAL thread_statistics= ON;
36+SET GLOBAL thread_statistics= @old_thread_statistics;
37
38=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test'
39--- Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test 2012-04-18 23:26:11 +0000
40+++ Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test 2012-05-14 14:38:21 +0000
41@@ -1,1 +1,4 @@
42 SELECT @@global.thread_statistics;
43+SET @old_thread_statistics= @@global.thread_statistics;
44+SET GLOBAL thread_statistics= ON;
45+SET GLOBAL thread_statistics= @old_thread_statistics;
46
47=== added file 'Percona-Server/mysql-test/t/percona_ssl_connections_count.test'
48--- Percona-Server/mysql-test/t/percona_ssl_connections_count.test 1970-01-01 00:00:00 +0000
49+++ Percona-Server/mysql-test/t/percona_ssl_connections_count.test 2012-05-14 14:38:21 +0000
50@@ -0,0 +1,79 @@
51+#
52+# Counting ssl connections test.
53+#
54+# CLIENT_STATISTICS, THREAD_STATISTICS, and USER_STATISTICS have
55+# a column TOTAL_CONNECTIONS_SSL to distinguish between these two types of
56+# connections.
57+#
58+
59+--source include/have_ssl_communication.inc
60+
61+# Save the initial number of concurrent sessions
62+--source include/count_sessions.inc
63+--disable_query_log
64+--disable_result_log
65+
66+
67+SET @old_userstat= @@global.userstat;
68+SET @old_thread_statistics= @@global.thread_statistics;
69+SET GLOBAL userstat= ON;
70+SET GLOBAL thread_statistics= ON;
71+
72+--let $sessions_count=3
73+
74+#create users
75+--let $i=$sessions_count
76+while ($i) {
77+--dec $i
78+--eval CREATE USER 'user_$i'@'localhost' IDENTIFIED BY 'mypass';
79+}
80+
81+#create ssl and non-ssl connections
82+--let $i=$sessions_count
83+while ($i) {
84+--dec $i
85+--connect (connection_ssl_$i,localhost,user_$i,mypass,,,,SSL)
86+ SELECT 1;
87+--connect (connection_$i,localhost,user_$i,mypass,,,,)
88+ SELECT 1;
89+}
90+
91+#get statistics
92+--enable_query_log
93+--enable_result_log
94+--connection default
95+
96+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
97+INFORMATION_SCHEMA.USER_STATISTICS ORDER BY USER;
98+
99+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
100+INFORMATION_SCHEMA.CLIENT_STATISTICS;
101+
102+SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
103+INFORMATION_SCHEMA.THREAD_STATISTICS ORDER BY THREAD_ID;
104+
105+--disable_query_log
106+--disable_result_log
107+
108+#close connections
109+--let $i=$sessions_count
110+while ($i) {
111+--dec $i
112+--disconnect connection_$i
113+--disconnect connection_ssl_$i
114+}
115+
116+--connection default
117+
118+--source include/wait_until_count_sessions.inc
119+
120+#remove users
121+--let $i=$sessions_count
122+while ($i) {
123+--dec $i
124+--eval DROP USER 'user_$i'@'localhost';
125+}
126+
127+SET GLOBAL userstat= @old_userstat;
128+SET GLOBAL thread_statistics= @old_thread_statistics;
129+
130
131=== modified file 'Percona-Server/sql/sql_connect.cc'
132--- Percona-Server/sql/sql_connect.cc 2012-04-19 16:51:34 +0000
133+++ Percona-Server/sql/sql_connect.cc 2012-05-14 14:38:21 +0000
134@@ -159,6 +159,7 @@
135 const char *user,
136 const char *priv_user,
137 uint total_connections,
138+ uint total_ssl_connections,
139 uint concurrent_connections,
140 time_t connected_time,
141 double busy_time,
142@@ -187,6 +188,7 @@
143 strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
144
145 user_stats->total_connections= total_connections;
146+ user_stats->total_ssl_connections= total_ssl_connections;
147 user_stats->concurrent_connections= concurrent_connections;
148 user_stats->connected_time= connected_time;
149 user_stats->busy_time= busy_time;
150@@ -212,6 +214,7 @@
151 void init_thread_stats(THREAD_STATS *thread_stats,
152 my_thread_id id,
153 uint total_connections,
154+ uint total_ssl_connections,
155 uint concurrent_connections,
156 time_t connected_time,
157 double busy_time,
158@@ -239,6 +242,7 @@
159 thread_stats->id= id;
160
161 thread_stats->total_connections= total_connections;
162+ thread_stats->total_ssl_connections= total_ssl_connections;
163 thread_stats->concurrent_connections= concurrent_connections;
164 thread_stats->connected_time= connected_time;
165 thread_stats->busy_time= busy_time;
166@@ -477,7 +481,7 @@
167 }
168
169 init_user_stats(user_stats, name, role_name,
170- 0, 0, // connections
171+ 0, 0, 0, // connections
172 0, 0, 0, // time
173 0, 0, 0, // bytes sent, received and written
174 0, 0, 0, // rows fetched, updated and read
175@@ -495,6 +499,8 @@
176 }
177 }
178 user_stats->total_connections++;
179+ if (thd->net.vio->type == VIO_TYPE_SSL)
180+ user_stats->total_ssl_connections++;
181 return 0;
182 }
183
184@@ -515,7 +521,7 @@
185 }
186
187 init_thread_stats(thread_stats, id,
188- 0, 0, // connections
189+ 0, 0, 0, // connections
190 0, 0, 0, // time
191 0, 0, 0, // bytes sent, received and written
192 0, 0, 0, // rows fetched, updated and read
193@@ -533,6 +539,8 @@
194 }
195 }
196 thread_stats->total_connections++;
197+ if (thd->net.vio->type == VIO_TYPE_SSL)
198+ thread_stats->total_ssl_connections++;
199 return 0;
200 }
201
202
203=== modified file 'Percona-Server/sql/sql_show.cc'
204--- Percona-Server/sql/sql_show.cc 2012-05-02 07:37:27 +0000
205+++ Percona-Server/sql/sql_show.cc 2012-05-14 14:38:21 +0000
206@@ -2467,6 +2467,7 @@
207 table->field[18]->store((longlong)user_stats->lost_connections);
208 table->field[19]->store((longlong)user_stats->access_denied_errors);
209 table->field[20]->store((longlong)user_stats->empty_queries);
210+ table->field[21]->store((longlong)user_stats->total_ssl_connections);
211 if (schema_table_store_record(thd, table))
212 {
213 DBUG_PRINT("error", ("store record error"));
214@@ -2504,6 +2505,7 @@
215 table->field[18]->store((longlong)user_stats->lost_connections);
216 table->field[19]->store((longlong)user_stats->access_denied_errors);
217 table->field[20]->store((longlong)user_stats->empty_queries);
218+ table->field[21]->store((longlong)user_stats->total_ssl_connections);
219 if (schema_table_store_record(thd, table))
220 {
221 DBUG_PRINT("error", ("store record error"));
222@@ -8082,6 +8084,7 @@
223 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
224 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
225 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
226+ {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
227 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
228 };
229
230@@ -8107,7 +8110,8 @@
231 {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections", SKIP_OPEN_TABLE},
232 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
233 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
234- {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
235+ {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
236+ {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
237 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
238 };
239
240@@ -8134,6 +8138,7 @@
241 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
242 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
243 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
244+ {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
245 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
246 };
247
248
249=== modified file 'Percona-Server/sql/sql_yacc.yy'
250--- Percona-Server/sql/sql_yacc.yy 2012-04-19 16:51:34 +0000
251+++ Percona-Server/sql/sql_yacc.yy 2012-05-14 14:38:21 +0000
252@@ -12801,6 +12801,7 @@
253 | TEMPTABLE_SYM {}
254 | TEXT_SYM {}
255 | THAN_SYM {}
256+ | THREAD_STATS_SYM {}
257 | TRANSACTION_SYM {}
258 | TRIGGERS_SYM {}
259 | TIMESTAMP {}
260
261=== modified file 'Percona-Server/sql/structs.h'
262--- Percona-Server/sql/structs.h 2012-04-18 23:26:01 +0000
263+++ Percona-Server/sql/structs.h 2012-05-14 14:38:21 +0000
264@@ -225,6 +225,7 @@
265 // Otherwise, the same value as user.
266 char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
267 uint total_connections;
268+ uint total_ssl_connections;
269 uint concurrent_connections;
270 time_t connected_time; // in seconds
271 double busy_time; // in seconds
272@@ -253,6 +254,7 @@
273 const char *user,
274 const char *priv_user,
275 uint total_connections,
276+ uint total_ssl_connections,
277 uint concurrent_connections,
278 time_t connected_time,
279 double busy_time,
280@@ -300,6 +302,7 @@
281 typedef struct st_thread_stats {
282 my_thread_id id;
283 uint total_connections;
284+ uint total_ssl_connections;
285 uint concurrent_connections;
286 time_t connected_time; // in seconds
287 double busy_time; // in seconds
288@@ -327,6 +330,7 @@
289 init_thread_stats(THREAD_STATS *thread_stats,
290 my_thread_id id,
291 uint total_connections,
292+ uint total_ssl_connections,
293 uint concurrent_connections,
294 time_t connected_time,
295 double busy_time,

Subscribers

People subscribed via source and target branches