Bug #117054 performance_schema tables are not accurate
Submitted: 27 Dec 2024 8:37
Reporter: Laurent F Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.20 8.0.40 OS:Any
Assigned to: CPU Architecture:Any

[27 Dec 2024 8:37] Laurent F
Description:
Tables of performance_schema are not accurate

CURRENT_NUMBER_OF_BYTES_USED seems to be the sum of all bytes used, not the current bytes used

it's growing.

Performance_schema
user    event_name      CURRENT_NUMBER_OF_BYTES_USED    HIGH_NUMBER_OF_BYTES_USED
user1      memory/sql/sp_head::main_mem_root       1589658104      1714391232
user2    memory/innodb/memory    1044595360      1045714408
NULL    memory/innodb/hash0hash 738056368       738056368
user2    memory/innodb/ha_innodb 354329064       354496648
user2    memory/sql/Log_event    249360672       251753568

How to repeat:
How to reproduce : 

Create few tables with triggers

Do some selects on thoses tables with differents parameters

close the connections to the db.

The CURRENT_NUMBER_OF_BYTES_USED is not reducing, but the memory of mysql is still the same for the OS.

mysql> select user, event_name, CURRENT_NUMBER_OF_BYTES_USED,HIGH_NUMBER_OF_BYTES_USED from memory_summary_by_user_by_event_name   order by CURRENT_NUMBER_OF_BYTES_USED desc limit 30;
+----------------+--------------------------------------+------------------------------+---------------------------+
| user           | event_name                           | CURRENT_NUMBER_OF_BYTES_USED | HIGH_NUMBER_OF_BYTES_USED |
+----------------+--------------------------------------+------------------------------+---------------------------+
| user1    | memory/sql/sp_head::main_mem_root    |                  17221004080 |               17238741053 |

it's look like a bug.

Same on MySQL 8.0.40