-
replicationLagQuery = How can this SQL accurately calculate replication lag? |
Beta Was this translation helpful? Give feedback.
Answered by
newborn22
Oct 18, 2023
Replies: 1 comment 1 reply
-
How does ReplTracker works? ReplTracker is a component that manages heartbeat table; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function
enableWrites
will start a ticker which writes timestamps to hearttable table at regular intervals.The replication lag refers to the time taken by the replic node to synchronise the binlog from the primary node.
Heartbeats inserted by the throttler to the primary node are synchronised to the replic nodes. When the throttler receives a request from the application, it requests data from the heartbeat table at a fixed interval. Then the heartbeat is subtracted from the select time to get the replication lag, the specific sql is
select unix_timestamp(now(6))-max(ts/1000000000) as replication_lag from mysql.heartbeat
While the method above can not accurately represent the replica…