Bug #109490 memory_summary_by_thread_by_event_name display wrong value
Submitted: 28 Dec 2022 3:39 Modified: 3 Jan 2023 14:19
Reporter: WANG FENG Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:8.0.24 OS:CentOS (7.7.1908)
Assigned to: CPU Architecture:x86 (x86_64)
Tags: memory_summary_by_thread_by_event_name memory/sql/Log_event

[28 Dec 2022 3:39] WANG FENG
Description:
The following query has a result that memory/sql/Log_event has 613486442008 memory using . However this value larger than total host memory a lot.

root@mysqldb 11:20:  [performance_schema]> select * from memory_summary_by_thread_by_event_name order by CURRENT_NUMBER_OF_BYTES_USED desc limit 3\G
*************************** 1. row ***************************
                   THREAD_ID: 55
                  EVENT_NAME: memory/sql/Log_event
                 COUNT_ALLOC: 1173183395
                  COUNT_FREE: 1756
   SUM_NUMBER_OF_BYTES_ALLOC: 613486762613
    SUM_NUMBER_OF_BYTES_FREE: 320605
              LOW_COUNT_USED: 0
          CURRENT_COUNT_USED: 1173181639
             HIGH_COUNT_USED: 1173181639
    LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 613486442008
   HIGH_NUMBER_OF_BYTES_USED: 613486442008
*************************** 2. row ***************************
                   THREAD_ID: 55
                  EVENT_NAME: memory/sql/HASH_ROW_ENTRY
                 COUNT_ALLOC: 73656118
                  COUNT_FREE: 0
   SUM_NUMBER_OF_BYTES_ALLOC: 6481738384
    SUM_NUMBER_OF_BYTES_FREE: 0
              LOW_COUNT_USED: 0
          CURRENT_COUNT_USED: 73656118
             HIGH_COUNT_USED: 73656118
    LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 6481738384
   HIGH_NUMBER_OF_BYTES_USED: 6481738384
*************************** 3. row ***************************
                   THREAD_ID: 53
                  EVENT_NAME: memory/sql/Gtid_set::Interval_chunk
                 COUNT_ALLOC: 81800320
                  COUNT_FREE: 66435091
   SUM_NUMBER_OF_BYTES_ALLOC: 16360063160
    SUM_NUMBER_OF_BYTES_FREE: 13287017480
              LOW_COUNT_USED: 0
          CURRENT_COUNT_USED: 15365229
             HIGH_COUNT_USED: 15365231
    LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 3073045680
   HIGH_NUMBER_OF_BYTES_USED: 3073046080
3 rows in set (0.01 sec)

The host memory is:
free -m 
              total        used        free      shared  buff/cache   available
Mem:          40185       29464         478        1160       10242        9299
Swap:          8063         561        7502

How to repeat:
As mentioned above.
[3 Jan 2023 14:19] MySQL Verification Team
Hi Mr. FENG,

Thank you for taking the time to report a problem.  Unfortunately you are not using a current release of the product you reported a problem with -- the problem might already be fixed. Please download a new release from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions, please  change the release on this bug report to the release you tested and we shall  change the status back to "Open".  

However, in order that we are able to change the status and in order to process this report, we require a fully repeatable test case, consisting of SQL statements that always lead to the result that you have got.

Again, thank you for your continued support of MySQL.
[3 Apr 2023 8:22] jifa Xu
8.0.32 still has the problem

memory/sql/Gtid_set::Interval_chunk
current_number_of_bytes_used 19G
but mysqld process only take 8G meomory
[3 Apr 2023 12:40] MySQL Verification Team
Hi,

MySQL server allocates a lot of memory on demand. When it has finished with the operation , it releases the memory.

Hence, timing in milliseconds can make a huge different in the result in the performance schema.

Also, do note that there are other reports in P_S that report memory usage ......