问题:今天,在做mysql binlog解析的时候,发现dump出来的数据出现严重的失序情况,时差差不多为1s
例如
SET TIMESTAMPE = 1
SET TIMESTAMPE = 0
SET TIMESTAMPE = 1
……
///
在写binlog头时:log_event.cc
Log_event::write_header
now= (ulong) get_time(); //query start time
int4store(header, now); // timestamp
log_event.h
inline time_t get_time()
{
THD *tmp_thd;
if (when)
return when;
if (thd)
return thd->start_time;
if ((tmp_thd= current_thd))
return tmp_thd->start_time;
return my_time(0);
}
///发现if when总是为正
于是跟进到上层binlog_query
case THD::STMT_QUERY_TYPE:
/*
The MYSQL_LOG::write() function wi
例如
SET TIMESTAMPE = 1
SET TIMESTAMPE = 0
SET TIMESTAMPE = 1
……
///
在写binlog头时:log_event.cc
Log_event::write_header
now= (ulong) get_time(); //query start time
int4store(header, now); // timestamp
log_event.h
inline time_t get_time()
{
THD *tmp_thd;
if (when)
return when;
if (thd)
return thd->start_time;
if ((tmp_thd= current_thd))
return tmp_thd->start_time;
return my_time(0);
}
///发现if when总是为正
于是跟进到上层binlog_query
case THD::STMT_QUERY_TYPE:
/*
The MYSQL_LOG::write() function wi

本文探讨了在解析MySQL binlog时遇到的时间戳失序问题,分析了从接收命令到执行过程中的时间戳设置,指出在高并发环境下可能导致先提交的SQL后执行,从而造成binlog记录的时间戳错乱。
最低0.47元/天 解锁文章
293

被折叠的 条评论
为什么被折叠?



