1 # name : log_connection_error.patch
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
9 +++ b/patch_info/log_connection_error.patch
11 +File=log_connection_error.patch
12 +Name=logging abandoned connections
14 +Author=Percona <info@percona.com>
19 @@ -4959,6 +4959,10 @@
21 DBUG_PRINT("error",("Too many connections"));
22 close_connection(thd, ER_CON_COUNT_ERROR);
23 + if (global_system_variables.log_warnings)
25 + sql_print_warning("%s", ER_DEFAULT(ER_CON_COUNT_ERROR));
30 @@ -5342,6 +5346,10 @@
31 if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) ||
32 my_net_init(&thd->net, thd->net.vio))
34 + if (global_system_variables.log_warnings)
36 + sql_print_warning("%s", ER_DEFAULT(ER_OUT_OF_RESOURCES));
38 close_connection(thd, ER_OUT_OF_RESOURCES);
41 @@ -5537,6 +5545,10 @@
42 event_conn_closed)) ||
43 my_net_init(&thd->net, thd->net.vio))
45 + if (global_system_variables.log_warnings)
47 + sql_print_warning("%s", ER_DEFAULT(ER_OUT_OF_RESOURCES));
49 close_connection(thd, ER_OUT_OF_RESOURCES);
53 +++ b/mysql-test/r/percona_log_connection_error.result
55 +SET @old_max_connections = @@max_connections;
56 +SET @old_log_warnings = @@log_warnings;
57 +SET GLOBAL max_connections=2;
58 +SET GLOBAL LOG_WARNINGS = 0;
59 +connect(localhost,root,,test,port,socket);
60 +ERROR HY000: Too many connections
61 +SET GLOBAL LOG_WARNINGS = 1;
62 +connect(localhost,root,,test,port,socket);
63 +ERROR HY000: Too many connections
64 +SET GLOBAL LOG_WARNINGS = 0;
65 +connect(localhost,root,,test,port,socket);
66 +ERROR HY000: Too many connections
67 +SET GLOBAL max_connections = @old_max_connections;
68 +SET GLOBAL log_warnings = @old_log_warnings;
69 +[log_grep.inc] file: percona.log_connection_error.err pattern: Too many connections
70 +[log_grep.inc] lines: 1
72 +++ b/mysql-test/t/percona_log_connection_error-master.opt
76 +++ b/mysql-test/t/percona_log_connection_error.test
78 +--source include/not_embedded.inc
80 +connect (main,localhost,root,,);
82 +SET @old_max_connections = @@max_connections;
83 +SET @old_log_warnings = @@log_warnings;
84 +SET GLOBAL max_connections=2;
85 +let $port=`SELECT Variable_value FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE Variable_name LIKE 'port'`;
86 +let $socket=`SELECT Variable_value FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE Variable_name LIKE 'socket'`;
88 +SET GLOBAL LOG_WARNINGS = 0;
89 +--connect (conn0,localhost,root,,)
91 +replace_result $port port $socket socket;
93 +--connect(conn1,localhost,root,,)
95 +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right
98 +SET GLOBAL LOG_WARNINGS = 1;
99 +--connect (conn1,localhost,root,,)
100 +replace_result $port port $socket socket;
102 +--connect (conn0,localhost,root,,)
104 +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right
107 +SET GLOBAL LOG_WARNINGS = 0;
108 +--connect (conn0,localhost,root,,)
109 +replace_result $port port $socket socket;
111 +--connect(conn1,localhost,root,,)
113 +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right
116 +SET GLOBAL max_connections = @old_max_connections;
117 +SET GLOBAL log_warnings = @old_log_warnings;
118 +let $log_error_= `SELECT @@GLOBAL.log_error`;
119 +if(!`select LENGTH('$log_error_')`)
121 + # MySQL Server on windows is started with --console and thus
122 + # does not know the location of its .err log, use default location
123 + let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err;
126 +--let log_error=$log_error_
127 +--let log_file=percona.log_connection_error.err
128 +--let log_file_full_path=$log_error
129 +--let grep_pattern= Too many connections
130 +--source include/log_grep.inc