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
=== added file 'Percona-Server/mysql-test/r/percona_ssl_connections_count.result'
--- Percona-Server/mysql-test/r/percona_ssl_connections_count.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/percona_ssl_connections_count.result 2012-05-14 14:38:21 +0000
@@ -0,0 +1,21 @@
1SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
2INFORMATION_SCHEMA.USER_STATISTICS ORDER BY USER;
3TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
41 0
52 1
62 1
72 1
8SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
9INFORMATION_SCHEMA.CLIENT_STATISTICS;
10TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
117 3
12SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
13INFORMATION_SCHEMA.THREAD_STATISTICS ORDER BY THREAD_ID;
14TOTAL_CONNECTIONS TOTAL_SSL_CONNECTIONS
151 0
161 1
171 0
181 1
191 0
201 1
211 0
022
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result 2012-04-18 23:26:11 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/thread_statistics_basic.result 2012-05-14 14:38:21 +0000
@@ -1,3 +1,6 @@
1SELECT @@global.thread_statistics;1SELECT @@global.thread_statistics;
2@@global.thread_statistics2@@global.thread_statistics
3030
4SET @old_thread_statistics= @@global.thread_statistics;
5SET GLOBAL thread_statistics= ON;
6SET GLOBAL thread_statistics= @old_thread_statistics;
47
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test 2012-04-18 23:26:11 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/thread_statistics_basic.test 2012-05-14 14:38:21 +0000
@@ -1,1 +1,4 @@
1SELECT @@global.thread_statistics;1SELECT @@global.thread_statistics;
2SET @old_thread_statistics= @@global.thread_statistics;
3SET GLOBAL thread_statistics= ON;
4SET GLOBAL thread_statistics= @old_thread_statistics;
25
=== added file 'Percona-Server/mysql-test/t/percona_ssl_connections_count.test'
--- Percona-Server/mysql-test/t/percona_ssl_connections_count.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/percona_ssl_connections_count.test 2012-05-14 14:38:21 +0000
@@ -0,0 +1,79 @@
1#
2# Counting ssl connections test.
3#
4# CLIENT_STATISTICS, THREAD_STATISTICS, and USER_STATISTICS have
5# a column TOTAL_CONNECTIONS_SSL to distinguish between these two types of
6# connections.
7#
8
9--source include/have_ssl_communication.inc
10
11# Save the initial number of concurrent sessions
12--source include/count_sessions.inc
13--disable_query_log
14--disable_result_log
15
16
17SET @old_userstat= @@global.userstat;
18SET @old_thread_statistics= @@global.thread_statistics;
19SET GLOBAL userstat= ON;
20SET GLOBAL thread_statistics= ON;
21
22--let $sessions_count=3
23
24#create users
25--let $i=$sessions_count
26while ($i) {
27--dec $i
28--eval CREATE USER 'user_$i'@'localhost' IDENTIFIED BY 'mypass';
29}
30
31#create ssl and non-ssl connections
32--let $i=$sessions_count
33while ($i) {
34--dec $i
35--connect (connection_ssl_$i,localhost,user_$i,mypass,,,,SSL)
36 SELECT 1;
37--connect (connection_$i,localhost,user_$i,mypass,,,,)
38 SELECT 1;
39}
40
41#get statistics
42--enable_query_log
43--enable_result_log
44--connection default
45
46SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
47INFORMATION_SCHEMA.USER_STATISTICS ORDER BY USER;
48
49SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
50INFORMATION_SCHEMA.CLIENT_STATISTICS;
51
52SELECT TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS FROM
53INFORMATION_SCHEMA.THREAD_STATISTICS ORDER BY THREAD_ID;
54
55--disable_query_log
56--disable_result_log
57
58#close connections
59--let $i=$sessions_count
60while ($i) {
61--dec $i
62--disconnect connection_$i
63--disconnect connection_ssl_$i
64}
65
66--connection default
67
68--source include/wait_until_count_sessions.inc
69
70#remove users
71--let $i=$sessions_count
72while ($i) {
73--dec $i
74--eval DROP USER 'user_$i'@'localhost';
75}
76
77SET GLOBAL userstat= @old_userstat;
78SET GLOBAL thread_statistics= @old_thread_statistics;
79
080
=== modified file 'Percona-Server/sql/sql_connect.cc'
--- Percona-Server/sql/sql_connect.cc 2012-04-19 16:51:34 +0000
+++ Percona-Server/sql/sql_connect.cc 2012-05-14 14:38:21 +0000
@@ -159,6 +159,7 @@
159 const char *user,159 const char *user,
160 const char *priv_user,160 const char *priv_user,
161 uint total_connections,161 uint total_connections,
162 uint total_ssl_connections,
162 uint concurrent_connections,163 uint concurrent_connections,
163 time_t connected_time,164 time_t connected_time,
164 double busy_time,165 double busy_time,
@@ -187,6 +188,7 @@
187 strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));188 strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
188189
189 user_stats->total_connections= total_connections;190 user_stats->total_connections= total_connections;
191 user_stats->total_ssl_connections= total_ssl_connections;
190 user_stats->concurrent_connections= concurrent_connections;192 user_stats->concurrent_connections= concurrent_connections;
191 user_stats->connected_time= connected_time;193 user_stats->connected_time= connected_time;
192 user_stats->busy_time= busy_time;194 user_stats->busy_time= busy_time;
@@ -212,6 +214,7 @@
212void init_thread_stats(THREAD_STATS *thread_stats,214void init_thread_stats(THREAD_STATS *thread_stats,
213 my_thread_id id,215 my_thread_id id,
214 uint total_connections,216 uint total_connections,
217 uint total_ssl_connections,
215 uint concurrent_connections,218 uint concurrent_connections,
216 time_t connected_time,219 time_t connected_time,
217 double busy_time,220 double busy_time,
@@ -239,6 +242,7 @@
239 thread_stats->id= id;242 thread_stats->id= id;
240243
241 thread_stats->total_connections= total_connections;244 thread_stats->total_connections= total_connections;
245 thread_stats->total_ssl_connections= total_ssl_connections;
242 thread_stats->concurrent_connections= concurrent_connections;246 thread_stats->concurrent_connections= concurrent_connections;
243 thread_stats->connected_time= connected_time;247 thread_stats->connected_time= connected_time;
244 thread_stats->busy_time= busy_time;248 thread_stats->busy_time= busy_time;
@@ -477,7 +481,7 @@
477 }481 }
478482
479 init_user_stats(user_stats, name, role_name,483 init_user_stats(user_stats, name, role_name,
480 0, 0, // connections484 0, 0, 0, // connections
481 0, 0, 0, // time485 0, 0, 0, // time
482 0, 0, 0, // bytes sent, received and written486 0, 0, 0, // bytes sent, received and written
483 0, 0, 0, // rows fetched, updated and read487 0, 0, 0, // rows fetched, updated and read
@@ -495,6 +499,8 @@
495 }499 }
496 }500 }
497 user_stats->total_connections++;501 user_stats->total_connections++;
502 if (thd->net.vio->type == VIO_TYPE_SSL)
503 user_stats->total_ssl_connections++;
498 return 0;504 return 0;
499}505}
500506
@@ -515,7 +521,7 @@
515 }521 }
516522
517 init_thread_stats(thread_stats, id,523 init_thread_stats(thread_stats, id,
518 0, 0, // connections524 0, 0, 0, // connections
519 0, 0, 0, // time525 0, 0, 0, // time
520 0, 0, 0, // bytes sent, received and written526 0, 0, 0, // bytes sent, received and written
521 0, 0, 0, // rows fetched, updated and read527 0, 0, 0, // rows fetched, updated and read
@@ -533,6 +539,8 @@
533 }539 }
534 }540 }
535 thread_stats->total_connections++;541 thread_stats->total_connections++;
542 if (thd->net.vio->type == VIO_TYPE_SSL)
543 thread_stats->total_ssl_connections++;
536 return 0;544 return 0;
537}545}
538546
539547
=== modified file 'Percona-Server/sql/sql_show.cc'
--- Percona-Server/sql/sql_show.cc 2012-05-02 07:37:27 +0000
+++ Percona-Server/sql/sql_show.cc 2012-05-14 14:38:21 +0000
@@ -2467,6 +2467,7 @@
2467 table->field[18]->store((longlong)user_stats->lost_connections);2467 table->field[18]->store((longlong)user_stats->lost_connections);
2468 table->field[19]->store((longlong)user_stats->access_denied_errors);2468 table->field[19]->store((longlong)user_stats->access_denied_errors);
2469 table->field[20]->store((longlong)user_stats->empty_queries);2469 table->field[20]->store((longlong)user_stats->empty_queries);
2470 table->field[21]->store((longlong)user_stats->total_ssl_connections);
2470 if (schema_table_store_record(thd, table))2471 if (schema_table_store_record(thd, table))
2471 {2472 {
2472 DBUG_PRINT("error", ("store record error"));2473 DBUG_PRINT("error", ("store record error"));
@@ -2504,6 +2505,7 @@
2504 table->field[18]->store((longlong)user_stats->lost_connections);2505 table->field[18]->store((longlong)user_stats->lost_connections);
2505 table->field[19]->store((longlong)user_stats->access_denied_errors);2506 table->field[19]->store((longlong)user_stats->access_denied_errors);
2506 table->field[20]->store((longlong)user_stats->empty_queries);2507 table->field[20]->store((longlong)user_stats->empty_queries);
2508 table->field[21]->store((longlong)user_stats->total_ssl_connections);
2507 if (schema_table_store_record(thd, table))2509 if (schema_table_store_record(thd, table))
2508 {2510 {
2509 DBUG_PRINT("error", ("store record error"));2511 DBUG_PRINT("error", ("store record error"));
@@ -8082,6 +8084,7 @@
8082 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},8084 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
8083 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},8085 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
8084 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},8086 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
8087 {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
8085 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}8088 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
8086};8089};
80878090
@@ -8107,7 +8110,8 @@
8107 {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections", SKIP_OPEN_TABLE},8110 {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections", SKIP_OPEN_TABLE},
8108 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},8111 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
8109 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},8112 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
8110 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},8113 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
8114 {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
8111 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}8115 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
8112};8116};
81138117
@@ -8134,6 +8138,7 @@
8134 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},8138 {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections", SKIP_OPEN_TABLE},
8135 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},8139 {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied", SKIP_OPEN_TABLE},
8136 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},8140 {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries", SKIP_OPEN_TABLE},
8141 {"TOTAL_SSL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_ssl_connections", SKIP_OPEN_TABLE},
8137 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}8142 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
8138};8143};
81398144
81408145
=== modified file 'Percona-Server/sql/sql_yacc.yy'
--- Percona-Server/sql/sql_yacc.yy 2012-04-19 16:51:34 +0000
+++ Percona-Server/sql/sql_yacc.yy 2012-05-14 14:38:21 +0000
@@ -12801,6 +12801,7 @@
12801 | TEMPTABLE_SYM {}12801 | TEMPTABLE_SYM {}
12802 | TEXT_SYM {}12802 | TEXT_SYM {}
12803 | THAN_SYM {}12803 | THAN_SYM {}
12804 | THREAD_STATS_SYM {}
12804 | TRANSACTION_SYM {}12805 | TRANSACTION_SYM {}
12805 | TRIGGERS_SYM {}12806 | TRIGGERS_SYM {}
12806 | TIMESTAMP {}12807 | TIMESTAMP {}
1280712808
=== modified file 'Percona-Server/sql/structs.h'
--- Percona-Server/sql/structs.h 2012-04-18 23:26:01 +0000
+++ Percona-Server/sql/structs.h 2012-05-14 14:38:21 +0000
@@ -225,6 +225,7 @@
225 // Otherwise, the same value as user.225 // Otherwise, the same value as user.
226 char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];226 char priv_user[max(USERNAME_LENGTH, LIST_PROCESS_HOST_LEN) + 1];
227 uint total_connections;227 uint total_connections;
228 uint total_ssl_connections;
228 uint concurrent_connections;229 uint concurrent_connections;
229 time_t connected_time; // in seconds230 time_t connected_time; // in seconds
230 double busy_time; // in seconds231 double busy_time; // in seconds
@@ -253,6 +254,7 @@
253 const char *user,254 const char *user,
254 const char *priv_user,255 const char *priv_user,
255 uint total_connections,256 uint total_connections,
257 uint total_ssl_connections,
256 uint concurrent_connections,258 uint concurrent_connections,
257 time_t connected_time,259 time_t connected_time,
258 double busy_time,260 double busy_time,
@@ -300,6 +302,7 @@
300typedef struct st_thread_stats {302typedef struct st_thread_stats {
301 my_thread_id id;303 my_thread_id id;
302 uint total_connections;304 uint total_connections;
305 uint total_ssl_connections;
303 uint concurrent_connections;306 uint concurrent_connections;
304 time_t connected_time; // in seconds307 time_t connected_time; // in seconds
305 double busy_time; // in seconds308 double busy_time; // in seconds
@@ -327,6 +330,7 @@
327init_thread_stats(THREAD_STATS *thread_stats,330init_thread_stats(THREAD_STATS *thread_stats,
328 my_thread_id id,331 my_thread_id id,
329 uint total_connections,332 uint total_connections,
333 uint total_ssl_connections,
330 uint concurrent_connections,334 uint concurrent_connections,
331 time_t connected_time,335 time_t connected_time,
332 double busy_time,336 double busy_time,

Subscribers

People subscribed via source and target branches