the row size is xx which is greater than maximum allowed size (8126 bytes) for a record on index leaf page

一个数据库DDL在MariaDB 10.3上没有任何问题,在MariaDB 10.6上就一般报这个问题:

[ERROR] InnoDB: Cannot add field `footer_color` in table `xxxx`.`theme` because after adding it, the row size is 8474 which is greater than maximum allowed size (8126 bytes) for a record on index leaf page.

这个Google一下很容易就知道是Row Size Too Large Error. 根据下面的文档很容易解决办法.

https://mariadb.com/kb/en/troubleshooting-row-size-too-large-errors-with-innodb/

但是按理说MariaDB 10.3 和 MariaDB 10.6上在这方面变动不大,为什么会出现问题呢?

搜索了半天,在MariaDB的文档上找到了说明:

https://mariadb.com/kb/en/innodb-row-formats-overview/#maximum-row-size

原来在MariaDB 10.2.26, 10.3.17, 10.4.7之前的版本上,InnoDB计算row size的方式是错误的,在后面的版本里修复了。

而我的MariaDB 10.3的版本正好是10.3.15.

困扰了一个上午的问题解决了!

另附解决办法,如果不想修改表的结构,可以在my.cnf添加下面的命令:

innodb_strict_mode = OFF

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.