-
Marc Alff authored
Before this fix, SELECT * from performance_schema.host_cache would return multiple rows with the same IP address. When iterating on the host_cache container, of type hash_filo, the iteration did not detect properly the list end, and caused to loop in the filo list again, causing the same entries to be displayed multiple times. The root cause for this is the way the hash_filo list is implemented. The 'first_link->prev_used' and 'last_link->next_used' are in fact garbage, never initialized properly and never maintained. During analysis, other severe flaws in the code were found. This fix: - initialize properly first_link and last_link when a container is initialized. - clean these members -- while the mutex lock is held --, in ::clear(), to avoid race conditions - sets 'first_link->prev_used' and 'last_link->next_used' to NULL, to cleary mark the beginning and end of the double linked list, when re ordering the list. Also, given that is it not intuitive that the caller has to hold a lock even to read and iterate on the list, several mysql_mutex_assert_owner() calls have been added where appropriate. To improve the usability of the performance_schema.host_cache table, in particular to decide how to size the host cache itself, the size of a row is now displayed by SHOW ENGINE PERFORMANCE_SCHEMA STATUS.
Marc Alff authoredBefore this fix, SELECT * from performance_schema.host_cache would return multiple rows with the same IP address. When iterating on the host_cache container, of type hash_filo, the iteration did not detect properly the list end, and caused to loop in the filo list again, causing the same entries to be displayed multiple times. The root cause for this is the way the hash_filo list is implemented. The 'first_link->prev_used' and 'last_link->next_used' are in fact garbage, never initialized properly and never maintained. During analysis, other severe flaws in the code were found. This fix: - initialize properly first_link and last_link when a container is initialized. - clean these members -- while the mutex lock is held --, in ::clear(), to avoid race conditions - sets 'first_link->prev_used' and 'last_link->next_used' to NULL, to cleary mark the beginning and end of the double linked list, when re ordering the list. Also, given that is it not intuitive that the caller has to hold a lock even to read and iterate on the list, several mysql_mutex_assert_owner() calls have been added where appropriate. To improve the usability of the performance_schema.host_cache table, in particular to decide how to size the host cache itself, the size of a row is now displayed by SHOW ENGINE PERFORMANCE_SCHEMA STATUS.
Loading