Skip to content

Commit

Permalink
Merge pull request #53 from jolivares/master
Browse files Browse the repository at this point in the history
avoid computing lag for events not having timestamp (HEARTBEAT)
  • Loading branch information
osheroff committed Nov 13, 2021
2 parents e503662 + 9bf861a commit a93b785
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.github.shyiko.mysql.binlog.BinaryLogClient;
import com.github.shyiko.mysql.binlog.event.Event;
import com.github.shyiko.mysql.binlog.event.EventHeader;
import com.github.shyiko.mysql.binlog.event.EventType;

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -65,6 +66,9 @@ public long getSecondsBehindMaster() {
if (timestamp == 0 || eventHeader == null) {
return -1;
}
if (eventHeader.getEventType() == EventType.HEARTBEAT && eventHeader.getTimestamp() == 0) {
return 0;
}
return (timestamp - eventHeader.getTimestamp()) / 1000;
}

Expand Down

0 comments on commit a93b785

Please sign in to comment.