Bug #81192 InnoDB doesn't allocate memory for the entire buffer pool at server startup
Submitted: 25 Apr 2016 11:22 Modified: 26 Apr 2016 13:38
Reporter: Charly Batista Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7 OS:CentOS
Assigned to: CPU Architecture:Any

[25 Apr 2016 11:22] Charly Batista
Description:
The documentation in [1] says: "InnoDB allocates memory for the entire buffer pool at server startup. Memory allocation is performed by malloc() operations". Until MySQL 5.6 the database tries to allocate the entire buffer pool and it fail when there is no enough memory. 

On MySQL 5.7 we can configure the buffer pool with more memory than available in the server and it will start. After a while when the DB needs more memory and try to allocate more memory it fails. 

Sometimes, depends on the chuck size the DB tries to add to the pool, it will cause segmentation fault or the kernel will kill the thread due OOM.

If check the 

[1] http://dev.mysql.com/doc/refman/5.7/en/memory-use.html

How to repeat:
To reproduce it edit the configuration file (my.cnf) and change the parameter innodb_buffer_pool_size = 2x the total of memory in the server ( 2 * (physical memory + swap)).

Connect to database and check the InnoDB status to see how much memory the database "think" it allocates:

mysql> show engine innodb status\G

It will show the value informed for innodb_buffer_pool_size (plus the adicional required memory)
[25 Apr 2016 11:25] Charly Batista
Tested on CentOS 6.7 64b using MySQL 5.7.11
[26 Apr 2016 13:38] MySQL Verification Team
Hi,

This is not a bug.

First and first of all, if you assign a very large InnoDB buffer pool, it will automatically be split into several smaller pools. That happened when I allocated 200 Gb of memory, for one benchmarks.

However, this is not important. What you report is NOT a bug for the very simple reason. UNIX systems do NOT allocate memory until it is accessed. When process in UNIX allocates some memory, UNIX only reserves it. It does not allocate it until it is accessed.

This is one of the basic concepts of every UNIX system.