Thank you for your help! If the status of the bug report you submitted changes, you will be notified. You may return here and check on the status or update your report at any time. That URL for your bug report is: http://bugs.mysql.com/107400.
Bug #107400 Contribution by Tencent:memory/innodb/buf_buf_pool incorrect after resize
Submitted: 26 May 2022 5:56 Modified: 3 Oct 2023 8:59
Reporter: yuxiang jiang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any
Tags: Contribution

[26 May 2022 5:56] yuxiang jiang
Description:
After resize innodb buffer pool size, we found that the value of memory/innodb/buf_buf_pool keep the same as previos in sys.memory_global_by_current_bytes.

How to repeat:
step 1
build a release version

step 2
set performance on in my.cnf as below

performance_schema=ON
performance-schema-instrument='memory/%=COUNTED'
innodb_buffer_pool_size=1G

step 3
start server
select * from sys.memory_global_by_current_bytes where event_name like '%buf_buf_pool%'\G
*************************** 1. row ***************************
       event_name: memory/innodb/buf_buf_pool
    current_count: 2
    current_alloc: 1.02 GiB
current_avg_alloc: 524.25 MiB
       high_count: 2
       high_alloc: 1.02 GiB
   high_avg_alloc: 524.25 MiB

step 4
resize buffer pool size

set global innodb_buffer_pool_size=2147483647;
select * from sys.memory_global_by_current_bytes where event_name like '%buf_buf_pool%'\G
*************************** 1. row ***************************
       event_name: memory/innodb/buf_buf_pool
    current_count: 2
    current_alloc: 1.02 GiB
current_avg_alloc: 524.25 MiB
       high_count: 2
       high_alloc: 1.02 GiB
   high_avg_alloc: 524.25 MiB
1 row in set (0.00 sec)

Suggested fix:
It seems that memory/innodbbuf_buf_pool is a global entry not a pfs_thread related entry. 

By change the definition of the entry as below in source file storage/innobase/ut/ut0new.cc.

{&mem_key_buf_buf_pool, "buf_buf_pool", PSI_FLAG_GLOBAL},

We can get the correct result.
[26 May 2022 6:14] MySQL Verification Team
Hello yuxiang jiang,

Thank you for the report and feedback.

regards,
Umesh
[29 May 2022 10:17] yuxiang jiang
follow up mixup

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: 0001-Fixup-in-correct-pfs-memory-innodb-buf_buf_pool-coun.patch (application/octet-stream, text), 4.04 KiB.

[30 Mar 2023 7:59] MySQL Verification Team
Bug #107397 marked as duplicate of this one
[3 Oct 2023 8:55] Marc ALFF
Thanks for the report, analysis, and contribution.

This has been fixed in 8.0 already:

mysql> select * from setup_instruments where NAME = 'memory/innodb/buf_buf_pool' \G
*************************** 1. row ***************************
         NAME: memory/innodb/buf_buf_pool
      ENABLED: YES
        TIMED: NULL
   PROPERTIES: global_statistics
        FLAGS: 
   VOLATILITY: 0
DOCUMENTATION: NULL
1 row in set (0.00 sec)

The fix was implemented by:

(MySQL bug)
Bug#90561 pfs memory statistics missing InnoDB buffer pool

(Oracle bug)
BUG#27917595 PFS MEMORY STATISTICS MISSING INNODB BUFFER POOL

Which is documented as:

 [7 Jun 2018 21:59] Daniel Price

Posted by developer:
 
Fixed as of the upcoming 8.0.13 release, and here's the changelog entry:

Buffer pool memory allocation was not fully accounted for in Performance
Schema memory/innodb/buf_buf_pool statistics.

---

When implementing the fix, the buffer pool was also instrumented as a global buffer, as visible with `PROPERTIES: global_statistics` in 8.0
[3 Oct 2023 8:59] Marc ALFF
Fixed in 8.0.13 by:

Bug#90561 pfs memory statistics missing InnoDB buffer pool