]>
Commit | Line | Data |
---|---|---|
b4e1fa2c AM |
1 | # name : log_connection_error.patch |
2 | # introduced : 12 | |
3 | # maintainer : Oleg | |
4 | # | |
5 | #!!! notice !!! | |
6 | # Any small change to this file in the main branch | |
7 | # should be done or reviewed by the maintainer! | |
db82db79 AM |
8 | --- /dev/null |
9 | +++ b/patch_info/log_connection_error.patch | |
b4e1fa2c AM |
10 | @@ -0,0 +1,6 @@ |
11 | +File=log_connection_error.patch | |
12 | +Name=logging abandoned connections | |
13 | +Version=1.0 | |
14 | +Author=Percona <info@percona.com> | |
15 | +License=GPL | |
16 | +Comment= | |
db82db79 AM |
17 | --- a/sql/mysqld.cc |
18 | +++ b/sql/mysqld.cc | |
29ffd636 | 19 | @@ -4959,6 +4959,10 @@ |
b4e1fa2c AM |
20 | |
21 | DBUG_PRINT("error",("Too many connections")); | |
d8778560 | 22 | close_connection(thd, ER_CON_COUNT_ERROR); |
b4e1fa2c AM |
23 | + if (global_system_variables.log_warnings) |
24 | + { | |
25 | + sql_print_warning("%s", ER_DEFAULT(ER_CON_COUNT_ERROR)); | |
26 | + } | |
27 | delete thd; | |
28 | DBUG_VOID_RETURN; | |
29 | } | |
29ffd636 | 30 | @@ -5342,6 +5346,10 @@ |
b4e1fa2c AM |
31 | if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) || |
32 | my_net_init(&thd->net, thd->net.vio)) | |
33 | { | |
34 | + if (global_system_variables.log_warnings) | |
35 | + { | |
36 | + sql_print_warning("%s", ER_DEFAULT(ER_OUT_OF_RESOURCES)); | |
37 | + } | |
d8778560 | 38 | close_connection(thd, ER_OUT_OF_RESOURCES); |
b4e1fa2c AM |
39 | delete thd; |
40 | continue; | |
29ffd636 | 41 | @@ -5537,6 +5545,10 @@ |
b4e1fa2c AM |
42 | event_conn_closed)) || |
43 | my_net_init(&thd->net, thd->net.vio)) | |
44 | { | |
45 | + if (global_system_variables.log_warnings) | |
46 | + { | |
47 | + sql_print_warning("%s", ER_DEFAULT(ER_OUT_OF_RESOURCES)); | |
48 | + } | |
d8778560 | 49 | close_connection(thd, ER_OUT_OF_RESOURCES); |
b4e1fa2c AM |
50 | errmsg= 0; |
51 | goto errorconn; | |
48b678b4 AM |
52 | --- /dev/null |
53 | +++ b/mysql-test/r/percona_log_connection_error.result | |
54 | @@ -0,0 +1,16 @@ | |
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 | |
71 | --- /dev/null | |
72 | +++ b/mysql-test/t/percona_log_connection_error-master.opt | |
73 | @@ -0,0 +1 @@ | |
74 | +--log-error | |
75 | --- /dev/null | |
76 | +++ b/mysql-test/t/percona_log_connection_error.test | |
77 | @@ -0,0 +1,54 @@ | |
78 | +--source include/not_embedded.inc | |
79 | + | |
80 | +connect (main,localhost,root,,); | |
81 | +connection main; | |
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'`; | |
87 | + | |
88 | +SET GLOBAL LOG_WARNINGS = 0; | |
89 | +--connect (conn0,localhost,root,,) | |
90 | +connection conn0; | |
91 | +replace_result $port port $socket socket; | |
92 | +--error 1040 | |
93 | +--connect(conn1,localhost,root,,) | |
94 | +disconnect conn0; | |
95 | +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right | |
96 | + | |
97 | +connection main; | |
98 | +SET GLOBAL LOG_WARNINGS = 1; | |
99 | +--connect (conn1,localhost,root,,) | |
100 | +replace_result $port port $socket socket; | |
101 | +--error 1040 | |
102 | +--connect (conn0,localhost,root,,) | |
103 | +disconnect conn1; | |
104 | +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right | |
105 | + | |
106 | +connection main; | |
107 | +SET GLOBAL LOG_WARNINGS = 0; | |
108 | +--connect (conn0,localhost,root,,) | |
109 | +replace_result $port port $socket socket; | |
110 | +--error 1040 | |
111 | +--connect(conn1,localhost,root,,) | |
112 | +disconnect conn0; | |
113 | +SLEEP 0.1; # tsarev: hack, but i don't know (and didn't find) how right | |
114 | + | |
115 | +connection main; | |
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_')`) | |
120 | +{ | |
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; | |
124 | +} | |
125 | + | |
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 | |
131 | + |