Bug #107556 restore_object_from_record on partition table consumes too much memory
Submitted: 14 Jun 1:52 Modified: 14 Jun 8:17
Reporter: Baolin Huang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Partitions Severity:S2 (Serious)
Version:8.0.29 OS:Any
Assigned to: CPU Architecture:Any
Tags: apply_dynamic_metadata OOM

[14 Jun 1:52] Baolin Huang
Description:
At instance startup, if a partitioned table exists and the number of partitions is large, the restore_object_from_record process consumes too much memory.

We tested that a partition table with 4096 partitions consumes more than 20g of memory at startup.

How to repeat:
1. create partition table

```
CREATE TABLE t (
  id int NOT NULL AUTO_INCREMENT,
  col1 int unsigned NOT NULL,
  col2 tinyint(1) NOT NULL,
  t1 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  t2 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id,col1),
  KEY ind1 (col1,col2,t1),
  KEY ind2 (t2)
) ENGINE=InnoDB /*!50100 PARTITION BY HASH (col1) PARTITIONS 4096 */ 
```

2. create procedure to keep inserting data

```
delimiter $$
CREATE PROCEDURE insert_1()
BEGIN
    ins: WHILE 1 DO
       insert into t(col1,col2) values(rand()*1000,111);
    END WHILE;
END $$
delimiter ;

call insert_1();
```

3. kill -9 `pidof mysqld` and restart the instance

4. top -p `pidof mysqld`  to check memory consumption
[14 Jun 3:30] Baolin Huang
The problem still exists on the latest 8.0.29
[14 Jun 8:17] MySQL Verification Team
Hello Baolin Huang,

Thank you for the report and test case.
Verified as described.

regards,
Umesh