Bug #119043 in certain situations the table space will be greatly wasted
Submitted: 19 Sep 9:14 Modified: 19 Sep 16:06
Reporter: peng gao Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.41 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[19 Sep 9:14] peng gao
Description:
hi team:

   If there are large records in the table but they do not exceed 8192, in certain situations, the table space will be greatly wasted.
   In repeat example record 6/7/8/9/10/11  in separate pages.

How to repeat:
CREATE TABLE `sbtest2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pad` varchar(12000),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

insert into sbtest2 values (10000, repeat('a',5120));
insert into sbtest2 values (10001, repeat('a',5120));
insert into sbtest2 values (1, repeat('a',5120));
insert into sbtest2 values (2, repeat('a',5120));
insert into sbtest2 values (3, repeat('a',5120));
insert into sbtest2 values (4, repeat('a',5120));
insert into sbtest2 values (5, repeat('a',5120));
insert into sbtest2 values (6,repeat('a',5120));
insert into sbtest2 values (7,repeat('a',5120));
insert into sbtest2 values (8,repeat('a',5120));
insert into sbtest2 values (9,repeat('a',5120));
insert into sbtest2 values (10,repeat('a',5120));
insert into sbtest2 values (11,repeat('a',5120));

Suggested fix:
At a certain moment, the page‘s records as follows

  block n            block x 
9   10000    -->     10001
   |
   |

insert rec 10

The current logic is:

block n   block n+1  block x
9  ---> 10 10000 --->  10001

block n space will be greatly wasted !  

This example key logic to insert an old page or a new split page,if insert new record to old page can be solved.

Like this :
 
 block n     block n+1    block x
9  10 --->  10000 --->     10001

 next new rec 11 insert to block n+1
 
  block n      block n    block x
9  10  ----> 11 10000 --> 10001

This way, the space won't be wasted. 

key logic:
  /* 6. The split and the tree modification is now completed. Decide the
  page where the tuple should be inserted */

  if (insert_left) {  
    insert_block = left_block; 
  } else {
    insert_block = right_block;
  }
[19 Sep 16:06] MySQL Verification Team
Thank you for your report but this is intended and expected behavior.