AnyShare - AnyShare 7.0 proton-mariadb pod 状态异常,数据库日志提示:Found 1 prepared transactions!
关键字
mariadb、异常关闭、事务回滚
适用产品
- AnyShare Enterprise 7.0.x
- AnyShare Express 7.0.x
问题描述
用户业务无法访问,mariadb 数据库无法正常运行,通过 tailf /sysvol/mariadb/mariadb_data/mysql-error.log 查看数据库错误日志提示:
Found 1 prepared transactions! It means that mysqld was not shut down properly last time and critical recovery information (last binlog or tc.log file) was manually deleted after a crash. You have to start mysqld with --tc-heuristic-recover switch to commit or rollback pending transactions.

问题影响
anyshare 命名空间下所有 pod 无法正常运行,用户无法访问 AnyShare。
问题原因
服务器异常关机,在关闭数据库 binlog 时,并未关闭 mysqld 进程,致使关闭 binlog 的过程当中还有事务进行。
解决方案
为了解决该问题,需要配置参数 tc-heuristic-recover ,请按照以下步骤执行:
1.通过 SSH 工具登录到需要加入 K8S 集群的 AnyShare master 节点 Linux 系统后台。
2.执行以下命令修改 mariadb 配置文件,添加参数 tc-heuristic-recover=ROLLBACK。
kubectl edit cm proton-mariadb-proton-rds-mariadb -nresource

3.执行以下命令 重启异常的 mariadb pod。
kubectl delete po -nresource proton-mariadb-proton-rds-mariadb-0
4.重启完成之后,执行以下命令观察 mariadb 错误日志输出,若出现提示:Please restart mysqld without --tc-heuristic-recover,参考步骤2,3,删除参数 tc-heuristic-recover=ROLLBACK,再次重启 pod。
tailf /sysvol/mariadb/mariadb_data/mysql-error.log

5.重启完成再次观察 mariadb 恢复正常。
更多信息
tc-heuristic-recover 参数在数据库崩溃恢复时,有两个值可以选择配置,分别是 COMMIT 或 ROLLBACK.