Description:
During database upgrades, the engine performs validation checks on all stored routines. When an instance contains an excessive number of routines, these validation processes consume substantial memory. Consequently, the instance experience an Out of Memory (OOM) error, causing the upgrade to fail.
How to repeat:
Launch an instance with 8.0.36 version on a linux based instance with 250G memory.
Create below number of objects on the instance. Here, higher number of Routines are the main reason.
MySQL [(none)]> select table_type, count(1) from information_schema.tables group by 1;
+-------------+----------+
| TABLE_TYPE | count(1) |
+-------------+----------+
| SYSTEM VIEW | 81 |
| BASE TABLE | 1200157 |
| VIEW | 1600102 |
+-------------+----------+
3 rows in set (10.512 sec)
MySQL [(none)]> select count(1) from information_schema.views;
+----------+
| count(1) |
+----------+
| 1600102 |
+----------+
1 row in set (5.776 sec)
MySQL [(none)]> select routine_type, count(1) from information_schema.routines group by routine_type;
+--------------+----------+
| ROUTINE_TYPE | count(1) |
+--------------+----------+
| FUNCTION | 50029 |
| PROCEDURE | 250084 |
+--------------+----------+
2 rows in set (1.038 sec)
MySQL [(none)]> select count(1) from information_schema.events;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.001 sec)
Example objects attached to the bug report - example objects.txt
Finally perform upgrade to 8.0.37, 8.0.41 or 8.0.42 - The upgrade operation fails and engine crash with out of memory.
Suggested fix:
Perform upgrade related checks or validations with in limited set of memory.
If possible then provide control over the memory being utilized during upgarde to improve the performance of the upgrade process.