| Bug #59738 | update a timestamp variable every time reaches Max_used_connections | ||
|---|---|---|---|
| Submitted: | 26 Jan 2011 11:47 | Modified: | 11 Mar 2014 21:13 |
| Reporter: | Jordi Prats (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Options | Severity: | S4 (Feature request) |
| Version: | 5.1 and 5.5 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | Contribution, max_used_connections, MySQL, patch | ||
[26 Jan 2011 11:52]
Jordi Prats
patch for that feature
Attachment: patch.mysql.51.max_used_connections_ts.patch (text/x-patch), 1.49 KiB.
[26 Jan 2011 12:15]
Valeriy Kravchuk
Thank you for the feature request and code contributed.
[29 Mar 2011 12:44]
Jordi Prats
Patch for MySQL 5.5.10
Attachment: patch.mysql.55.max_used_connections_ts.patch (text/x-patch), 1.95 KiB.
[29 Mar 2011 12:47]
Jordi Prats
Attached a new patch for MySQL 5.5
[12 Feb 2014 9:17]
Jordi Prats
same patch for mysql 5.1 (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: patch.mysql.51.max_used_connections_ts.patch (text/x-patch), 1.49 KiB.
[12 Feb 2014 9:17]
Jordi Prats
same patch for mysql 5.5 (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: patch.mysql.55.max_used_connections_ts.patch (text/x-patch), 1.95 KiB.
[11 Mar 2014 21:13]
Paul DuBois
Noted in 5.7.5 changelog. A new status variable, Max_used_connections_time, indicates the time at which Max_used_connections reached its current value. Thanks to Jordi Prats for the patch.

Description: Max_used_connections works as a high-water mark, so, you cannot know if it reached that level just a minute ago or at server startup. It be nice to have a timestamp updated every time it reaches that level. How to repeat: show variables like 'Max_used%'; Suggested fix: MySQL 5.1: diff -Naur mysql-5.1.53 mysql-5.1.53_max_used_ts/ diff -Naur mysql-5.1.53/sql/mysqld.cc mysql-5.1.53_max_used_ts/sql/mysqld.cc --- mysql-5.1.53/sql/mysqld.cc 2010-11-03 14:39:53.000000000 +0100 +++ mysql-5.1.53_max_used_ts/sql/mysqld.cc 2011-01-26 11:21:58.000000000 +0100 @@ -418,6 +418,7 @@ static uint kill_cached_threads, wake_thread; static ulong killed_threads, thread_created; static ulong max_used_connections; +static ulong max_used_connections_ts; static ulong my_bind_addr; /**< the address we bind to */ static volatile ulong cached_thread_count= 0; static const char *sql_mode_str= "OFF"; @@ -5020,6 +5021,10 @@ if (connection_count > max_used_connections) max_used_connections= connection_count; + if (connection_count >= max_used_connections) + max_used_connections_ts= (ulong)my_time(0);; + + pthread_mutex_unlock(&LOCK_connection_count); /* Start a new thread to handle connection. */ @@ -7655,6 +7660,7 @@ {"Key_writes", (char*) offsetof(KEY_CACHE, global_cache_write), SHOW_KEY_CACHE_LONGLONG}, {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, + {"Max_used_connections_ts", (char*) &max_used_connections_ts, SHOW_LONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH}, {"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH}, {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFL