修复Mariadb升级后报错 Incorrect definition of table mysql.column_stats

docker compose 模式部署的 gitea 在某次更新之后开始大量出现如下报错:

1
2
Feb 12 17:23:37 VM-0-16-ubuntu gitea_compose_giteadb_1[3927]: 2024-02-12  9:23:37 3103704 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255).
Feb 12 17:23:37 VM-0-16-ubuntu gitea_compose_giteadb_1[3927]: 2024-02-12 9:23:37 3103704 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'hist_type' at position 9 to have type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), found type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')

错误量非常巨大给syslog打崩了, 日志滚动的时候负载特别高会出现无法连接的问题. 经排查发现是mariadb升级的时候没有自动升级库表结构引起. 在 docker-compose.yml mariadb 中添加 MARIADB_AUTO_UPGRADE=1 环境变量再 docker-compose up -d 即可修复.

参考

Incorrect definition of table mysql.column_stats: expected column ‘hist_type’ … #25970

mariadb docker README