当前位置:网站首页>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));如何获得精确的毫秒级的主从延迟
总结
公众号

看到这里的你,如果对于我写的内容很感兴趣,有任何疑问,欢迎在下面留言,会第一次时间给大家解答,谢谢!
边栏推荐
- Asynchronous FIFO
- 别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
- 再立云计算“昆仑”,联想混合云Lenovo xCloud凭什么?
- LeetCode_ Backtracking_ Dynamic programming_ Medium_ 131. split palindrome string
- 冒泡排序 指针
- Autoincrement attribute of sqlserver replication table
- Web Caching Technology
- MySQL master-slave synchronization and its basic process of database and table division
- Finding the value of the nth term of Fibonacci sequence by recursion
- 如何使用enum数据类型
猜你喜欢

JSBridge

异步FIFO

C sqlsugar, hisql, FreeSQL ORM framework all-round performance test vs. sqlserver performance test

Common operations of sourcetree version management

DCC888 :SSA (static single assignment form)

swagger2 使用方法

tp5.1上传excel文件并读取其内容

Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!

c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试

别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
随机推荐
Express、路由(Route)、Request对象、Response对象、中间件、EJS模板
冒泡排序 指针
斐波那契数列合集
OJ每日一练——找第一个只出现一次的字符
C language greedy snake
获取鼠标移动的方向
OJ daily practice - delete word suffixes
How to use swagger2
Web Caching Technology
c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试
Redis cache
IPV4的未来替代品!一文读懂IPV6的优势特点和地址类型
Autoincrement attribute of sqlserver replication table
Sword finger offer 06 Print linked list from end to end
Problèmes rencontrés lors de l'utilisation de redistemplate
OJ daily practice - word length
node-fetch下载文件
输出字符串中最长的单词
China Mobile's mobile phone users grow slowly, but strive for high profit 5g package users
Canvas generate Poster