Comment 6 for bug 1661488

Revision history for this message
Nickolay Ihalainen (ihanick) wrote :

https://github.com/facebook/mysql-5.6.git

reload_acl_and_cache => if (options & REFRESH_STATISTICS) => reset_global_user_stats https://github.com/facebook/mysql-5.6/blob/9cbb76e8505ee343b91de537a8212e8a384cec9b/sql/sql_connect.cc#L1234

Loops against all user connections and resets stats.

User statistics in facebook mysql is a part of user resources, thus it's not working in the same way as in original google patches or percona/mariadb, e.g. number of concurrent connections obtained from user resources.

But anyway both google and facebook implementations looping. So I can:
- loop accross all hash items (my_hash_element for(0;<global_user_stats.records))
- my_hash_delete item if concurrent_connections == 0
- cut user_stats values from init_user_stats to separate reset_user_stats function (it could be possible to use init_user_stats to reset values, but it uses strncpy(user_stats->user, user, sizeof(user_stats->user)); and if user_stats->user will be the same pointer as user it should be UB, because strncpy defined with restrict: extern char *strncpy (char *__restrict __dest, const char *__restrict __src, size_t __n) ) or allow to have init_user_stats user=NULL and do not use strncpy if user parameter is null to re-init already existing user stats.