# InnoDB assertion failure crash when altering then optimizing table after upgrade from MySQL 5.7 to 8.0

**URL:** <https://forums.percona.com/t/innodb-assertion-failure-crash-when-altering-then-optimizing-table-after-upgrade-from-mysql-5-7-to-8-0/24287>\
**Category:** Percona Server for MySQL\
**Created:** [August 7, 2023, 11:10pm UTC](https://forums.percona.com/t/innodb-assertion-failure-crash-when-altering-then-optimizing-table-after-upgrade-from-mysql-5-7-to-8-0/24287 "2023-08-07T23:10:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [August 8, 2023, 5:40pm UTC](https://forums.percona.com/t/innodb-assertion-failure-crash-when-altering-then-optimizing-table-after-upgrade-from-mysql-5-7-to-8-0/24287/6 "2023-08-08T17:40:39Z")

</div>

@resuni,  
If you’re on ZFS, BTRFS, EBS, or use LVM, you can use snapshots to make this process quicker. 🙂

Here is the patch for the fix with comments from Oracle

> <https://github.com/mysql/mysql-server/commit/cc6a7059093>
>
> Background:
> When tables are loaded in mem cache (dict\_table\_t) they go through
> … fill\_dict\_table() which makes sure all in mem metadata is updated
> for the tables correctly.
> 
> But in case of upgrade from 5.7, tables are loaded in dict\_table\_t
> cache from dict\_load\_table(). And then it remains in cache to be used.
> 
> Issue:
> During upgrade, when the table is loaded from dict\_load\_table(), it
> doesn't set the initial/current/total/\_column\_count metadata of
> dict\_table\_t. Which causes issues when table is used after INSTANT
> ADD/DROP DDL.
> 
> Note this is done only once and next server restarts, the table is
> loaded from fill\_dict\_table() function. And this is why if there is a
> restart after upgrade, the issue is not seen.
> 
> Fix:
> Made sure when the table is loaded from dict\_load\_table() during
> upgrade, the column count metadata is also set correctly.
> 
> Change-Id: I7729a9e03683737bfe8b3025203f31551b710f70

Based on Oracle’s comments, my guess is that since Xtrabackup “cleans” the state of InnoDB before starting MySQL 8, the issue isn’t seen. But when you do a direct 5.7-\>8, the incorrect state from 5.7 remains in cache and mysql 8, on first start, did not clean that cache properly.

---

_[View the full topic](https://forums.percona.com/t/innodb-assertion-failure-crash-when-altering-then-optimizing-table-after-upgrade-from-mysql-5-7-to-8-0/24287)._
