diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index a10be32e8..865514980 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -105,6 +105,7 @@ class MySQL_HostGroups_Manager { public: struct { + unsigned int servers_table_version; unsigned long client_connections_aborted; unsigned long client_connections_created; int client_connections; @@ -151,6 +152,7 @@ class MySQL_HostGroups_Manager { void replication_lag_action(int, char*, unsigned int, int); void read_only_action(char *hostname, int port, int read_only); + unsigned int get_servers_table_version(); }; #endif /* __CLASS_MYSQL_HOSTGROUPS_MANAGER_H */ diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index c126a1a47..d3f8b3112 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -229,6 +229,7 @@ MySQL_HostGroups_Manager::MySQL_HostGroups_Manager() { status.server_connections_connected=0; status.server_connections_aborted=0; status.server_connections_created=0; + status.servers_table_version=0; status.myconnpoll_get=0; status.myconnpoll_get_ok=0; status.myconnpoll_get_ping=0; @@ -281,6 +282,10 @@ void MySQL_HostGroups_Manager::wrunlock() { spin_wrunlock(&rwlock); } +unsigned int MySQL_HostGroups_Manager::get_servers_table_version() { + return __sync_fetch_and_add(&status.servers_table_version,0); +} + // add a new row in mysql_servers_incoming // we always assume that the calling thread has acquired a rdlock() bool MySQL_HostGroups_Manager::server_add(unsigned int hid, char *add, uint16_t p, unsigned int _weight, enum MySerStatus status, unsigned int _comp /*, uint8_t _charset */, unsigned int _max_connections, unsigned int _max_replication_lag) { @@ -403,6 +408,7 @@ bool MySQL_HostGroups_Manager::commit() { generate_mysql_servers_table(); generate_mysql_replication_hostgroups_table(); + __sync_fetch_and_add(&status.servers_table_version,1); wrunlock(); if (GloMTH) { GloMTH->signal_all_threads(1); diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 06ddf5c49..b6874ebf0 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1986,6 +1986,12 @@ SQLite3_result * MySQL_Threads_Handler::SQL3_GlobalStatus() { pta[1]=buf; result->add_row(pta); } + { // Slow queries + pta[0]=(char *)"Servers_table_version"; + sprintf(buf,"%u",MyHGM->get_servers_table_version()); + pta[1]=buf; + result->add_row(pta); + } free(pta); return result; }