当前位置:网站首页>MySQL-Seconds_behind_master 的精度误差
MySQL-Seconds_behind_master 的精度误差
2022-06-22 21:25:00 【HeapDump性能社区】
前言
问题现场

网络问题

long time_diff= ((long)(time(0) - mi->rli->last_master_timestamp) - mi->clock_diff_with_master);
什么时候计算 clock_diff_with_master
handle_slave_io /* 建立主从连接 */ |->safe_connect(thd, mysql, mi)) /* connected: 主从连接成功后,计算一下主从clock_diff_with_master */ |->get_master_version_and_clockclock_diff_with_master 跨秒误差



long time_diff= ((long)(time(0) - mi->rli->last_master_timestamp) - mi->clock_diff_with_master); /* Apparently on some systems time_diff can be <0. Here are possible reasons related to MySQL: - the master is itself a slave of another master whose time is ahead. - somebody used an explicit SET TIMESTAMP on the master. Possible reason related to granularity-to-second of time functions (nothing to do with MySQL), which can explain a value of -1: assume the master's and slave's time are perfectly synchronized, and that at slave's connection time, when the master's timestamp is read, it is at the very end of second 1, and (a very short time later) when the slave's timestamp is read it is at the very beginning of second 2. Then the recorded value for master is 1 and the recorded value for slave is 2. At SHOW SLAVE STATUS time, assume that the difference between timestamp of slave and rli->last_master_timestamp is 0 (i.e. they are in the same second), then we get 0-(2-1)=-1 as a result. This confuses users, so we don't go below 0: hence the max(). last_master_timestamp == 0 (an "impossible" timestamp 1970) is a special marker to say "consider we have caught up". */ protocol->store((longlong)(mi->rli->last_master_timestamp ? max(0L, time_diff) : 0));如何获得精确的毫秒级的主从延迟
总结
公众号

看到这里的你,如果对于我写的内容很感兴趣,有任何疑问,欢迎在下面留言,会第一次时间给大家解答,谢谢!
边栏推荐
- wallys/WiFi6 MiniPCIe Module 2T2R 2 × 2.4GHz 2x5GHz
- 弱电转职业网工难不难?华为售前工程师分享亲身经历
- OJ daily practice - find the first character that only appears once
- OJ每日一练——病毒的增生
- 剑指 Offer 11. 旋转数组的最小数字
- Digital data was invited to participate in Nantong enterprise digital transformation Seminar
- Eslint simple configuration
- Express、路由(Route)、Request对象、Response对象、中间件、EJS模板
- 14. 最长公共前缀
- 为什么现在大家都不用外键了(二)?
猜你喜欢

Do domestic mobile phones turn apples? It turned out that it was realized by 100 yuan machine and sharp price reduction

考过HCIP依然转行失败,职业网工最看重的到底是什么

同步电路与跨时钟域电路设计2——多bit信号的跨时钟域传输(FIFO)

canvas生成海报

异步FIFO
![[STM32 skill] use the hardware I2C of STM32 Hal library to drive rx8025t real-time clock chip](/img/32/88321db57afb50ccc096d687ff9c41.png)
[STM32 skill] use the hardware I2C of STM32 Hal library to drive rx8025t real-time clock chip

mysql主从同步及其分库分表基本流程

JSBridge

弱电转职业网工难不难?华为售前工程师分享亲身经历

Optimization - linear programming
随机推荐
Programmers' choice of taking private jobs and part-time jobs
Ensure database and cache consistency
os.Args[1:]中命令行参数为空时,不执行内部语句
flink同步mysql数据到ES
OLAP ——Druid简介
OJ每日一练——过滤多余的空格
14. longest common prefix
同步电路与跨时钟域电路设计2——多bit信号的跨时钟域传输(FIFO)
Safe and reliable! Tianyi cloud data security management platform passed the evaluation
Redis cache
斐波那契数列合集
[STM32 skill] use the hardware I2C of STM32 Hal library to drive rx8025t real-time clock chip
OJ每日一练——整理命名
mysql主从同步及其分库分表基本流程
OJ每日一练——找第一个只出现一次的字符
OJ daily practice - filter extra spaces
Common operations of sourcetree version management
os. When the command line parameter in args[1:] is empty, the internal statement will not be executed
Good things to share
Webrtc series - 4connection sorting of network transmission