关于 MySQL、PostgresSQL、Mariadb 数据库2038千年虫问题

MySQL

测试时间:2023-8

启动MySQL服务后,将系统时间调制2038年01月19日03时14分07秒之后的日期,发现MySQL服务自动停止。

根据最新的MySQL源码(mysql-8.1.0)分析,sql/sql_parse.cc中依然存在2038年千年虫问题

c++ 复制代码
/*
      If the time has gone past end of epoch we need to shutdown the server. But
      there is possibility of getting invalid time value on some platforms.
      For example, gettimeofday() might return incorrect value on solaris
      platform. Hence validating the current time with 5 iterations before
      initiating the normal server shutdown process because of time getting
      past 2038.
*/
if (tries > max_tries) {
     /*
        If the time has got past epoch, we need to shut this server down.
        We do this by making sure every command is a shutdown and we
        have enough privileges to shut the server down

        TODO: remove this when we have full 64 bit my_time_t support
      */
     LogErr(ERROR_LEVEL, ER_UNSUPPORTED_DATE);
     const ulong master_access = thd->security_context()->master_access();
     thd->security_context()->set_master_access(master_access | SHUTDOWN_ACL);
     error = true;
     kill_mysql();
 }

TODO: remove this when we have full 64 bit my_time_t support:表示直到MySQL完成支持64位时间戳时才移除这个限制

PostgreSQL

测试时间:2023-8

测试版本:psql-10.1、psql-15.4

启动postgresql服务后,将系统时间调制2038年01月19日03时14分07秒之后的日期,psql-15.4版服务正常运行,数据库可以正常读写;但是重启服务postgresql失败(也就是说postgresql在2038年后无法正常启动)。psql-10.1服务直接挂掉,不能使用。

日志分析:


从日志上可以看出,调整时间后,重启postgresql,日志中的记录时间有问题;启动过程中一直报"D:/PostgresSQL/15/share/timezone"目录不存在,这个问题可能是postgresql获取时区出了问题(有可能是系统的问题)。

Mariadb

测试时间:2023-8

测试版本:10.8.8,11.1.2-GA(测试日期的最新版)

现象与PostgreSQL类似,调整时间后能正常读写,但是不能重启。(未分析日志)

从Mariadb的官网上,可以查到旧版计划(5.6版本)中就有用关于解决2038年千年虫问题的计划;好像未彻底实时(Mariadb不存在5.6版本)。

总结

距离下一次千年虫还有15年的时间,但愿MySQL能修复这个问题;不过按照Oracle的德性,不排除到了2038年停止MySQL社区版的维护,强制用户升级到企业版(大赚一笔)。

Mariadb、PostgreSQL 未来几年修复千年虫问题的可能性还是比较大的(毕竟已经修复了一部分),我们尽请期待吧。

相关推荐
I Am a robert girl1 小时前
从 GameHorizon 拆解多时间尺度游戏评测:数据管线、离线基准与在线回放的三层设计
数据库·游戏·多时间尺度·数据管线·游戏评测·离线基准·在线回放
躺柒1 小时前
读数据安全架构设计与实践17安全架构案例(下)
数据库·安全·零信任·安全架构·防火墙·无边界
SelectDB1 小时前
实时更新排错现场:导入了却查到旧数据,和 FINAL 越加越慢的两条路
大数据·数据库·数据分析
SelectDB2 小时前
拿 Planet 的账单一行行对下来,我总结出三个可自查的校验点
大数据·数据库·数据分析
SelectDB2 小时前
Apache Doris + Vane:让多模态数据进入业务分析
大数据·数据库·数据分析
pjj198544 小时前
ClickHouse 与 Doris 数据库技术梳理:看懂分析型数据库
数据库·clickhouse
1024奇点4 小时前
【仓颉语言入门 · 第二篇 第 12 课】
开发语言·数据库·ide·mysql·开源
冰暮流星4 小时前
mysql之insert优化
数据库·mysql
北方的银狐-Zero5 小时前
OntoL 7.0|面向工业多智能体的语义本体套件,让异构系统真正 “看懂彼此”——OntoL的本体产品矩阵
人工智能·mysql·sqlite·1024程序员节·本体论·本体产品
海鸥-w5 小时前
数据库冗余字段设计笔记
java·数据库·笔记·oracle