Skip to content

Commit fc4bc58

Browse files
committed
Misc cleanup
1 parent f2bd193 commit fc4bc58

12 files changed

+48
-40
lines changed

mysql-test/suite/perfschema/r/hostcache_ipv4_max_con.result

+1
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@ FIRST_ERROR_SEEN set
918918
LAST_ERROR_SEEN set
919919
set global max_user_connections = 0;
920920
set global max_connections = 3;
921+
flush user_resources;
921922
select "Con4a is alive";
922923
Con4a is alive
923924
Con4a is alive

mysql-test/suite/perfschema/r/hostcache_ipv6_max_con.result

+1
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@ FIRST_ERROR_SEEN set
918918
LAST_ERROR_SEEN set
919919
set global max_user_connections = 0;
920920
set global max_connections = 3;
921+
flush user_resources;
921922
select "Con4a is alive";
922923
Con4a is alive
923924
Con4a is alive

mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test

+13
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ connect (con2e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
7676
--connection default
7777
--source ../include/hostcache_dump.inc
7878

79+
# Wait for all disconnects
80+
--source ../include/wait_for_pfs_thread_count.inc
81+
7982
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
8083
with max_connections_per_hour 0;
8184
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
@@ -123,6 +126,9 @@ disconnect con3a;
123126
disconnect con3b;
124127
disconnect con3c;
125128

129+
# Wait for all disconnects
130+
--source ../include/wait_for_pfs_thread_count.inc
131+
126132
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
127133
with max_user_connections 0;
128134
flush user_resources;
@@ -170,8 +176,12 @@ disconnect con4a;
170176
disconnect con4b;
171177
disconnect con4c;
172178

179+
# Wait for all disconnects
180+
--source ../include/wait_for_pfs_thread_count.inc
181+
173182
set global max_user_connections = 0;
174183
set global max_connections = 3;
184+
flush user_resources;
175185

176186
connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
177187
select "Con4a is alive";
@@ -206,6 +216,9 @@ connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
206216
disconnect con5a;
207217
disconnect con5b;
208218

219+
# Wait for all disconnects
220+
--source ../include/wait_for_pfs_thread_count.inc
221+
209222
set global max_connections = @saved_max_connections;
210223

211224
# revoke all privileges on test.* from 'quota'@'santa.claus.ipv4.example.com';

mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test

+13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ connect (con2e,"::1",quota,,test,$MASTER_MYPORT,);
7777
--connection default
7878
--source ../include/hostcache_dump.inc
7979

80+
# Wait for all disconnects
81+
--source ../include/wait_for_pfs_thread_count.inc
82+
8083
grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
8184
with max_connections_per_hour 0;
8285
grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
@@ -124,6 +127,9 @@ disconnect con3a;
124127
disconnect con3b;
125128
disconnect con3c;
126129

130+
# Wait for all disconnects
131+
--source ../include/wait_for_pfs_thread_count.inc
132+
127133
grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
128134
with max_user_connections 0;
129135
flush user_resources;
@@ -171,8 +177,12 @@ disconnect con4a;
171177
disconnect con4b;
172178
disconnect con4c;
173179

180+
# Wait for all disconnects
181+
--source ../include/wait_for_pfs_thread_count.inc
182+
174183
set global max_user_connections = 0;
175184
set global max_connections = 3;
185+
flush user_resources;
176186

177187
connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
178188
select "Con4a is alive";
@@ -207,6 +217,9 @@ connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
207217
disconnect con5a;
208218
disconnect con5b;
209219

220+
# Wait for all disconnects
221+
--source ../include/wait_for_pfs_thread_count.inc
222+
210223
set global max_connections = @saved_max_connections;
211224

212225
# revoke all privileges on test.* from 'quota'@'santa.claus.ipv6.example.com';

scripts/mysql_system_tables.sql

-1
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ SET @cmd="CREATE TABLE performance_schema.host_cache("
629629
"COUNT_SSL_ERRORS BIGINT not null,"
630630
"COUNT_MAX_USER_CONNECTION_ERRORS BIGINT not null,"
631631
"COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS BIGINT not null,"
632-
"COUNT_MAX_CONNECTION_ERRORS BIGINT not null,"
633632
"COUNT_DEFAULT_DATABASE_ERRORS BIGINT not null,"
634633
"COUNT_INIT_CONNECT_ERRORS BIGINT not null,"
635634
"COUNT_LOCAL_ERRORS BIGINT not null,"

sql/hostname.cc

-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Host_errors::Host_errors()
6565
m_ssl(0),
6666
m_max_user_connection(0),
6767
m_max_user_connection_per_hour(0),
68-
m_max_connection(0),
6968
m_default_database(0),
7069
m_init_connect(0),
7170
m_local(0)
@@ -94,7 +93,6 @@ void Host_errors::reset()
9493
m_ssl= 0;
9594
m_max_user_connection= 0;
9695
m_max_user_connection_per_hour= 0;
97-
m_max_connection= 0;
9896
m_default_database= 0;
9997
m_init_connect= 0;
10098
m_local= 0;
@@ -120,7 +118,6 @@ void Host_errors::aggregate(const Host_errors *errors)
120118
m_ssl+= errors->m_ssl;
121119
m_max_user_connection+= errors->m_max_user_connection;
122120
m_max_user_connection_per_hour+= errors->m_max_user_connection_per_hour;
123-
m_max_connection+= errors->m_max_connection;
124121
m_default_database+= errors->m_default_database;
125122
m_init_connect+= errors->m_init_connect;
126123
m_local+= errors->m_local;

sql/hostname.h

-3
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ struct Host_errors
6969
ulong m_max_user_connection;
7070
/** Number of errors from max user connection per hour. */
7171
ulong m_max_user_connection_per_hour;
72-
/** Number of errors from max connection. */
73-
ulong m_max_connection;
7472
/** Number of errors from the default database. */
7573
ulong m_default_database;
7674
/** Number of errors from init_connect. */
@@ -97,7 +95,6 @@ struct Host_errors
9795
|| (m_ssl != 0)
9896
|| (m_max_user_connection != 0)
9997
|| (m_max_user_connection_per_hour != 0)
100-
|| (m_max_connection != 0)
10198
|| (m_default_database != 0)
10299
|| (m_init_connect != 0)
103100
|| (m_local != 0));

sql/mysqld.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -5406,6 +5406,7 @@ void create_thread_to_handle_connection(THD *thd)
54065406
mysql_mutex_unlock(&LOCK_connection_count);
54075407

54085408
statistic_increment(aborted_connects,&LOCK_status);
5409+
statistic_increment(connection_internal_errors, &LOCK_status);
54095410
/* Can't use my_error() since store_globals has not been called. */
54105411
my_snprintf(error_message_buff, sizeof(error_message_buff),
54115412
ER_THD(thd, ER_CANT_CREATE_THREAD), error);
@@ -5414,7 +5415,6 @@ void create_thread_to_handle_connection(THD *thd)
54145415
mysql_mutex_lock(&LOCK_thread_count);
54155416
delete thd;
54165417
mysql_mutex_unlock(&LOCK_thread_count);
5417-
connection_internal_errors++;
54185418
return;
54195419
/* purecov: end */
54205420
}
@@ -5455,7 +5455,7 @@ static void create_new_thread(THD *thd)
54555455
DBUG_PRINT("error",("Too many connections"));
54565456
close_connection(thd, ER_CON_COUNT_ERROR);
54575457
delete thd;
5458-
connection_max_connection_errors++;
5458+
statistic_increment(connection_max_connection_errors, &LOCK_status);
54595459
DBUG_VOID_RETURN;
54605460
}
54615461

@@ -5585,7 +5585,7 @@ void handle_connections_sockets()
55855585
There is not much details to report about the client,
55865586
increment the server global status variable.
55875587
*/
5588-
connection_select_errors++;
5588+
statistic_increment(connection_select_errors, &LOCK_status);
55895589
if (!select_errors++ && !abort_loop) /* purecov: inspected */
55905590
sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
55915591
}
@@ -5667,7 +5667,7 @@ void handle_connections_sockets()
56675667
There is not much details to report about the client,
56685668
increment the server global status variable.
56695669
*/
5670-
connection_accept_errors++;
5670+
statistic_increment(connection_accept_errors, &LOCK_status);
56715671
if ((error_count++ & 255) == 0) // This can happen often
56725672
sql_perror("Error in accept");
56735673
MAYBE_BROKEN_SYSCALL;
@@ -5710,7 +5710,7 @@ void handle_connections_sockets()
57105710
The connection was refused by TCP wrappers.
57115711
There are no details (by client IP) available to update the host_cache.
57125712
*/
5713-
connection_tcpwrap_errors++;
5713+
statistic_increment(connection_tcpwrap_errors, &LOCK_status);
57145714
continue;
57155715
}
57165716
}
@@ -5725,7 +5725,7 @@ void handle_connections_sockets()
57255725
{
57265726
(void) mysql_socket_shutdown(new_sock, SHUT_RDWR);
57275727
(void) mysql_socket_close(new_sock);
5728-
connection_internal_errors++;
5728+
statistic_increment(connection_internal_errors, &LOCK_status);
57295729
continue;
57305730
}
57315731

@@ -5750,7 +5750,7 @@ void handle_connections_sockets()
57505750
(void) mysql_socket_close(new_sock);
57515751
}
57525752
delete thd;
5753-
connection_internal_errors++;
5753+
statistic_increment(connection_internal_errors, &LOCK_status);
57545754
continue;
57555755
}
57565756
init_net_server_extension(thd);

sql/sql_acl.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -9640,9 +9640,7 @@ acl_authenticate(THD *thd, uint com_change_user_pkt_len)
96409640
mysql_mutex_unlock(&LOCK_connection_count);
96419641
if (!count_ok)
96429642
{ // too many connections
9643-
Host_errors errors;
9644-
errors.m_max_connection= 1;
9645-
inc_host_errors(mpvio.ip, &errors);
9643+
statistic_increment(connection_max_connection_errors, &LOCK_status);
96469644
my_error(ER_CON_COUNT_ERROR, MYF(0));
96479645
DBUG_RETURN(1);
96489646
}

sql/sql_connect.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ bool init_new_connection_handler_thread()
444444
pthread_detach_this_thread();
445445
if (my_thread_init())
446446
{
447-
connection_internal_errors++;
447+
statistic_increment(connection_internal_errors, &LOCK_status);
448448
return 1;
449449
}
450450
return 0;
@@ -562,7 +562,7 @@ static int check_connection(THD *thd)
562562
this is treated as a global server OOM error.
563563
TODO: remove the need for my_strdup.
564564
*/
565-
connection_internal_errors++;
565+
statistic_increment(connection_internal_errors, &LOCK_status);
566566
return 1; /* The error is set by my_strdup(). */
567567
}
568568
thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;
@@ -627,7 +627,7 @@ static int check_connection(THD *thd)
627627
Hence, there is no reason to account on OOM conditions per client IP,
628628
we count failures in the global server status instead.
629629
*/
630-
connection_internal_errors++;
630+
statistic_increment(connection_internal_errors, &LOCK_status);
631631
return 1; /* The error is set by alloc(). */
632632
}
633633

storage/perfschema/table_host_cache.cc

+9-18
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,6 @@ static const TABLE_FIELD_TYPE field_types[]=
132132
{ C_STRING_WITH_LEN("bigint(20)") },
133133
{ NULL, 0}
134134
},
135-
{
136-
{ C_STRING_WITH_LEN("COUNT_MAX_CONNECTION_ERRORS") },
137-
{ C_STRING_WITH_LEN("bigint(20)") },
138-
{ NULL, 0}
139-
},
140135
{
141136
{ C_STRING_WITH_LEN("COUNT_DEFAULT_DATABASE_ERRORS") },
142137
{ C_STRING_WITH_LEN("bigint(20)") },
@@ -181,7 +176,7 @@ static const TABLE_FIELD_TYPE field_types[]=
181176

182177
TABLE_FIELD_DEF
183178
table_host_cache::m_field_def=
184-
{ 30, field_types };
179+
{ 29, field_types };
185180

186181
PFS_engine_table_share
187182
table_host_cache::m_share=
@@ -301,7 +296,6 @@ void table_host_cache::make_row(Host_entry *entry, row_host_cache *row)
301296
row->m_count_ssl_errors= entry->m_errors.m_ssl;
302297
row->m_count_max_user_connection_errors= entry->m_errors.m_max_user_connection;
303298
row->m_count_max_user_connection_per_hour_errors= entry->m_errors.m_max_user_connection_per_hour;
304-
row->m_count_max_connection_errors= entry->m_errors.m_max_connection;
305299
row->m_count_default_database_errors= entry->m_errors.m_default_database;
306300
row->m_count_init_connect_errors= entry->m_errors.m_init_connect;
307301
row->m_count_local_errors= entry->m_errors.m_local;
@@ -440,34 +434,31 @@ int table_host_cache::read_row_values(TABLE *table,
440434
case 20: /* COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS */
441435
set_field_ulonglong(f, m_row->m_count_max_user_connection_per_hour_errors);
442436
break;
443-
case 21: /* COUNT_MAX_CONNECTION_ERRORS */
444-
set_field_ulonglong(f, m_row->m_count_max_connection_errors);
445-
break;
446-
case 22: /* COUNT_DEFAULT_DATABASE_ERRORS */
437+
case 21: /* COUNT_DEFAULT_DATABASE_ERRORS */
447438
set_field_ulonglong(f, m_row->m_count_default_database_errors);
448439
break;
449-
case 23: /* COUNT_INIT_CONNECT_ERRORS */
440+
case 22: /* COUNT_INIT_CONNECT_ERRORS */
450441
set_field_ulonglong(f, m_row->m_count_init_connect_errors);
451442
break;
452-
case 24: /* COUNT_LOCAL_ERRORS */
443+
case 23: /* COUNT_LOCAL_ERRORS */
453444
set_field_ulonglong(f, m_row->m_count_local_errors);
454445
break;
455-
case 25: /* COUNT_UNKNOWN_ERRORS */
446+
case 24: /* COUNT_UNKNOWN_ERRORS */
456447
set_field_ulonglong(f, m_row->m_count_unknown_errors);
457448
break;
458-
case 26: /* FIRST_SEEN */
449+
case 25: /* FIRST_SEEN */
459450
set_field_timestamp(f, m_row->m_first_seen);
460451
break;
461-
case 27: /* LAST_SEEN */
452+
case 26: /* LAST_SEEN */
462453
set_field_timestamp(f, m_row->m_last_seen);
463454
break;
464-
case 28: /* FIRST_ERROR_SEEN */
455+
case 27: /* FIRST_ERROR_SEEN */
465456
if (m_row->m_first_error_seen != 0)
466457
set_field_timestamp(f, m_row->m_first_error_seen);
467458
else
468459
f->set_null();
469460
break;
470-
case 29: /* LAST_ERROR_SEEN */
461+
case 28: /* LAST_ERROR_SEEN */
471462
if (m_row->m_last_error_seen != 0)
472463
set_field_timestamp(f, m_row->m_last_error_seen);
473464
else

storage/perfschema/table_host_cache.h

-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ struct row_host_cache
7878
ulonglong m_count_max_user_connection_errors;
7979
/** Column COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS. */
8080
ulonglong m_count_max_user_connection_per_hour_errors;
81-
/** Column COUNT_MAX_CONNECTION_ERRORS. */
82-
ulonglong m_count_max_connection_errors;
8381
/** Column COUNT_DEFAULT_DATABASE_ERRORS. */
8482
ulonglong m_count_default_database_errors;
8583
/** Column COUNT_INIT_CONNECT_ERRORS. */

0 commit comments

Comments
 (0)